# Convert the Markdown emitted by release-notes.sh to a safe LaTeX appendix. # Escape character by character so commit messages cannot become TeX commands. function tex(value, result, i, c) { result = "" for (i = 1; i <= length(value); i++) { c = substr(value, i, 1) if (c == "\\") result = result "\\textbackslash{}" else if (c == "{" || c == "}" || c == "$" || c == "&" || c == "#" || c == "_" || c == "%") result = result "\\" c else if (c == "~") result = result "\\textasciitilde{}" else if (c == "^") result = result "\\textasciicircum{}" else if (c == "`") result = result "\\textasciigrave{}" else result = result c } return result } BEGIN { print "% Generated by the Build LaTeX stage; do not edit." print "\\chapter{Release Notes}" print "\\label{release-notes}" print "\\begingroup\\raggedright" } /^# Changes in / { print "\\section*{" tex(substr($0, 3)) "}" next } /^- / { if (!items) { print "\\begin{itemize}"; items = 1 } print "\\item " tex(substr($0, 3)) next } { if (items) { print "\\end{itemize}"; items = 0 } print tex($0) } END { if (items) print "\\end{itemize}" print "\\endgroup" }