md2tex: Two bugs prevented graceful handling of ampersands in headings

This commit is contained in:
Nero 2024-03-26 21:58:23 +00:00
parent a59d19fa3d
commit 2ea260dbf1

6
md2tex
View File

@ -42,7 +42,7 @@ function inline(text) {
gsub(/_/, "\\_", text) gsub(/_/, "\\_", text)
gsub(/#/, "\\#", text) gsub(/#/, "\\#", text)
gsub(/%/, "\\%", text) gsub(/%/, "\\%", text)
gsub(/&/, "\\&", text) gsub(/&/, "\\\\&", text)
gsub(/\^/, "\\textasciicircum ", text) gsub(/\^/, "\\textasciicircum ", text)
gsub(/\.{3,}/, "\\ldots", text) gsub(/\.{3,}/, "\\ldots", text)
text = gensub(/\*\*([^\*]*)\*\*/, "\\textbf{\\1}", "g", text) text = gensub(/\*\*([^\*]*)\*\*/, "\\textbf{\\1}", "g", text)
@ -88,13 +88,13 @@ function inline(text) {
t="section" t="section"
for (i=3; i<=d; i++) t="sub"t for (i=3; i<=d; i++) t="sub"t
gsub(/^#* /, "", $0) gsub(/^#* /, "", $0)
tag(t"{" $0 "}") tag(t"{" inline($0) "}")
next next
} }
/^### / { /^### / {
gsub(/^#* /, "", $0) gsub(/^#* /, "", $0)
tag("subsection{" $0 "}") tag("subsection{" inline($0) "}")
next next
} }