GithubHelp home page GithubHelp logo

ox-clip's Introduction

ox-clip - Cross-platform Formatted copy commands for org-mode

This module copies selected regions in org-mode as formatted text on the clipboard that can be pasted into other applications. When not in org-mode, the htmlize library is used instead.

For Windows the html-clip-w32.py script will be installed in the ox-clip install directory. It works pretty well, but I noticed that the hyperlinks in the TOC to headings don’t work, and strike-through doesn’t seem to work. I have no idea how to fix either issue.

Mac OSX needs textutils and pbcopy, which should be part of the standard utilities available on MacOSX.

Linux needs a relatively modern xclip. https://github.com/astrand/xclip

There is one command: ox-clip-formatted-copy that should work across Windows, Mac and Linux. I recommend you bind this to a key. I like H-k (Hyper-k).

Note: This file was extracted from https://github.com/jkitchin/scimax to make a smaller repo for MELPA (see jkitchin/scimax#21). I extracted it using this git wizardry from: http://www.pixelite.co.nz/article/extracting-file-folder-from-git-repository-with-full-git-history/. This seems to have retained the history on the file modifications.

cd /path/to/scimax
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- ox-clip.el > /tmp/patch

cd ~/tmp
mkdir ox-clip
git init
git am < /tmp/patch
git remote add origin [email protected]:jkitchin/ox-clip.git
git push -f origin master

ox-clip's People

Contributors

epost avatar grettke avatar jkitchin avatar maxnikulin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ox-clip's Issues

Keeping line breaks in numbered lists

Is it possible to keep line breaks and not break numbers for lists like this one? Or just regular line breaks?

For example:

1. Line 1
   Line 2 with indentation
2. Line 3
3. etc.

Error on Windows 10 using ox-clip-formatted-copy

I'm on Windows 10 trying to use the ox-clip-formatted-copy command. It seems to work at first, but then I get a *Shell Command Output* buffer that says the following:

Traceback (most recent call last):
  File "c:\Users\John\.emacs.d\elpa\ox-clip-20210528.2059\html-clip-w32.py", line 227, in PutToClipboard
    win32clipboard.OpenClipboard(0)
pywintypes.error: (5, 'OpenClipboard', 'Access is denied.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\John\.emacs.d\elpa\ox-clip-20210528.2059\html-clip-w32.py", line 268, in <module>
    PutHtml(data)
  File "c:\Users\John\.emacs.d\elpa\ox-clip-20210528.2059\html-clip-w32.py", line 42, in PutHtml
    cb.PutFragment(fragment)
  File "c:\Users\John\.emacs.d\elpa\ox-clip-20210528.2059\html-clip-w32.py", line 218, in PutFragment
    self.PutToClipboard(html, fragmentStart, fragmentEnd, selectionStart, selectionEnd, source)
  File "c:\Users\John\.emacs.d\elpa\ox-clip-20210528.2059\html-clip-w32.py", line 232, in PutToClipboard
    win32clipboard.CloseClipboard()
pywintypes.error: (1418, 'CloseClipboard', 'Thread does not have a clipboard open.')

I did some searching for the error and believe it relates to the clipboard being in use by too many programs at a small moment in time, as explained at https://stackoverflow.com/questions/60751385/python-how-to-slove-the-problem-pywintypes-error-5-openclipboard-access

Do you think that's the problem? I've reproduced the issue on multiple Windows machines. Any help would be much appreciated!

pbcopy Doesn't Work with Firefox or Slack

I've found that while I can paste content into Chrome, there's nothing pasted in Firefox or Slack.

After a lot of troubleshooting I realized it's because the text attribute of the clipboard needs to be set (even if it's blank 🤷) and came up with this solution using Apple Script:

echo "<b>bolded text</b>" |\
hexdump -ve '1/1 "%.2x"' |\
xargs printf "set the clipboard to {text:\" \", «class HTML»:«data HTML%s»}" |\
osascript -

Any issue with using this approach for ox-clip-osx-cmd?

Problems with file encoding on Windows 10

Hello, I'm having some trouble using ox-clip-formatted-copy in windows, probably related to file encoding systems. Copying "1. A validação de créditos extra-curriculares" resulted in "validação de créditos extra-curriculares". The original file encoding was "utf-8-dos" and I've tried changing it to "latin-1" and "Windows-1256" with set-buffer-file-coding-system to no effect.
Is there some solution or patch I can add?
Thanks in advance

Can't copy TeX formula from org-mode

Maybe I'm doing something wrong, but I can not copy the preview of the tex formula from orgmode
I am using Doom Emacs
Copying images works great though

P.S. It's says: Symbol's function definition is void: ov-at

Improper method to create a temporary file

Predictable file name in the /tmp directory hardly could be considered as good practice.

https://github.com/jkitchin/ox-clip/blob/master/ox-clip.el#L369

(with-temp-file "/tmp/ox-clip-org.html"

There is at least make-temp-file function, see info '(elisp)Unique File Names', though I do not know if it is the best option.

Another system user could create file or symlink with such name causing permission denied error.

Fortunately, nowadays it is at least unlikely a security vulnerability since fs.protected_symlinks should be turned on by default.

https://www.kernel.org/doc/Documentation/sysctl/fs.txt

A long-standing class of security issues is the symlink-based
time-of-check-time-of-use race, most commonly seen in world-writable
directories like /tmp. The common method of exploitation of this flaw
is to cross privilege boundaries when following a given symlink (i.e. a
root process follows a symlink belonging to another user). For a likely
incomplete list of hundreds of examples across the years, please see:
http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=/tmp

When set to "0", symlink following behavior is unrestricted.

When set to "1" symlinks are permitted to be followed only when outside
a sticky world-writable directory, or when the uid of the symlink and
follower match, or when the directory owner matches the symlink's owner.

This protection is based on the restrictions in Openwall and grsecurity.

P.S. I like the idea to bypass emacs limitations in respect to clipboard format by using an external utility.

option to export more than the visible region

https://github.com/jkitchin/ox-clip/blob/master/ox-clip.el#L388:
ox-clip-formatted-copy uses the following org-export-to-buffer options:

	       (buf (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t))
  • subtreep = nil
  • visible-only = t

This means that to copy a subtree, I need to:

  • org-mark-subtree (C-c @)
  • org-cycle (TAB) until the subtree is visible
  • ox-clip-formatted-copy (in my case C-S-M-w)

Please:

  • Could you add a function ox-clip-formatted-copy-subtree to do that, even if not all of the subtree is visible?
  • Or maybe a parameter ox-clip-only-visible to control the value visible-only when invoking org-export-to-buffer? I think I like this variant better since it is natural to use org-mark-subtree (C-c @) if I want to copy it or formatted-copy it.

Thanks!

Unicode Support?

This plugin works great for converting pretty output to HTML (so you can, for example, paste to GMail). Are you aware of a way to make it work for unicode copy (so that you could, for example, paste pretty output to a browser search bar)?

Support wayland on linux

wl-clipboard is the equivalent of xclip

echo $XDG_SESSION_TYPE
wayland

wl-copy < /tmp/ox-clip-xSIpzg.html

Cheers

Text with backslashes and formatting is cut when copied

I noticed that when I have something like this:
*%appdata%\Path\Path\Path*
then when I use ox-clip (either on Windows natively or on Linux), it will be copied without slashes, and everything after the backslash including the backslash will be cut. It doesn't happen if I replace it with regular slashes, but for Windows paths I would prefer the backslash.

So I get this (with formatting):
%appdata%

It doesn't matter what text I have, I just noticed that in this particular case.

It happens with _underlined text here_, /italics text here/, *bold text here*, but not with ~code text here~ (so I use this one and then change the formatting in place).

I tried double-backslashes, but it didn't help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.