Skip to content

Instantly share code, notes, and snippets.

@schoettl
Created November 7, 2016 20:51
Show Gist options
  • Save schoettl/d098d424ea88bbcf8d1ba4d5505b373e to your computer and use it in GitHub Desktop.
Save schoettl/d098d424ea88bbcf8d1ba4d5505b373e to your computer and use it in GitHub Desktop.
#!/bin/bash
# utf82latex - Convert UTF-8 encoded input to ASCII encoded LaTeX
# warning:
# does not work if input contains double quotes (") or back slashes (\)
# usage:
# in Vim: :%!utf82latex
# in shell: xclip -o -selection c | utf82latex | xclip -selection c
# in shell: utf82latex <<EOF | xclip -selection c
# see also:
# clipboard-utf82latex - short for clipboard usage example above
while read -r line; do
R -q --vanilla <<EOF 2>&1 >/dev/null
library(tools)
message(encoded_text_to_latex("$line", "UTF-8"))
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment