Skip to content

Instantly share code, notes, and snippets.

@trnila
Created May 19, 2019 16:40
Show Gist options
  • Save trnila/e152a7c591943f8bd639aa7e9bf36771 to your computer and use it in GitHub Desktop.
Save trnila/e152a7c591943f8bd639aa7e9bf36771 to your computer and use it in GitHub Desktop.
Fix hardspaces for czech language in LaTeX
#!/bin/sh
awk -i inplace -f - "$1" << 'AWK'
BEGIN {
skip = 0
IGNORECASE=1
}
/\\begin{(minted|lstlisting|tikzpicture)}/ {
skip = 1
}
/\\end{(minted|lstlisting|tikzpicture)}/ {
skip = 0
}
{
if(skip == 0) {
print gensub(/(^|\s+)(k|s|v|z|o|u|a|i) /, "\\1\\2~", "g")
} else {
print $0
}
}
AWK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment