Last active
August 6, 2020 13:17
-
-
Save RichardBronosky/c2d609b721df3ecc771c4980e9f6b63f to your computer and use it in GitHub Desktop.
This is my solution to the Evernote bug https://discussion.evernote.com/forums/topic/120108-copy-paste-in-code-block-double-the-empty-lines/
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
#!/bin/bash | |
convert_text(){ | |
python3 -c 'import html, sys; [print(html.escape(l), end="") for l in sys.stdin]' | \ | |
sed -E $' | |
1i\\\n<span style="-en-clipboard:true;"><br/></span><div style="-en-codeblock:true;"><div>\n | |
s, ,\ ,g | |
s,$,<br/>, | |
s,^<br/>$,<div><br/></div>, | |
$a\\\n</div></div>\n | |
' | |
} | |
convert_clipboard(){ | |
osascript -e "set the clipboard to «data HTML$(pbpaste | hexdump -ve '1/1 "%.2x"')»" | |
} | |
main(){ | |
pbpaste | convert_text | pbcopy | |
convert_clipboard | |
} | |
self_test(){ | |
convert_text <$BASH_SOURCE | |
} | |
if [[ ${1:-} == "-t" ]]; then | |
self_test | |
else | |
main | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment