-
-
Save Laeeth/7d63d1c7022f2bd3f4a83f4098361327 to your computer and use it in GitHub Desktop.
Convert rich text on the clipboard to Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi | |
# for my .vimrc: | |
# command PasteMarkdown :read !if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi | |
# nnoremap ,pmd :PasteMarkdown<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment