diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-04 12:26:52 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-04 12:26:52 +0200 |
commit | 8961c2bed80314d79c3d642765128d85632f18e4 (patch) | |
tree | c8235e22d3f7c96fb6538a69d6067ec2f83ce3b2 /templates/latex/presentation/scripts | |
parent | feat(common/init): Safe the %INIT_ variables for later use (diff) | |
download | flake-templates-8961c2bed80314d79c3d642765128d85632f18e4.tar.gz flake-templates-8961c2bed80314d79c3d642765128d85632f18e4.zip |
feat(templates/latex/presentation): Init
Diffstat (limited to 'templates/latex/presentation/scripts')
-rwxr-xr-x | templates/latex/presentation/scripts/fix_notes.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/templates/latex/presentation/scripts/fix_notes.sh b/templates/latex/presentation/scripts/fix_notes.sh new file mode 100755 index 0000000..c5caf5b --- /dev/null +++ b/templates/latex/presentation/scripts/fix_notes.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +# Compiling this document with pdflatex, will leave all utf8 chars in the `\note`s +# mangled. But, `pdfpc` interprets them as markdown, thus replacing all of them with their +# respective html entities results in them looking correct in during the presentation. +# +# This script automatically replaces them in the source files. +# +# # Known Bugs +# It does not account for `\note`s spanning multiple lines. So, for example, this would not +# be fixed: +# ```latex +# \note { +# Ästhetik ist hierbei nicht mit den Wundern der Kunst zu verwechseln. +# } +# ``` + +rg '\\note' --files-with-matches | while IFS= read -r file; do + [ "$(basename "$file")" = "$(basename "$0")" ] && continue + + echo "Fixing: '$file'" + sed --in-place 's/^\(.*\)\\note\(.*\){\(.*\)}/printf "%s\\\\\\note%s{%s}" "\1" "\2" "$( echo "\3" | sed "s@ä@\\\ä\;@g" | sed "s@ö@\\\ö\;@g" | sed "s@ü@\\\ü\;@g" | sed "s@Ä@\\\Ä\;@g" | sed "s@Ö@\\\Ö\;@g" | sed "s@Ü@\\\Ü\;@g" | sed "s@ß@\\\ß\;@g" | sed "s@→@\\\&rarr\;@g" )"/eg' "$file" +done |