arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
Improve markdown math normalization for KaTeX rendering
Pau Escrich p4u@dabax.net
Fri, 27 Feb 2026 13:15:57 +0100
commit

412bd20ee2446aee38cf68de85816888f3de22b3

parent

c177ce3cabe0a8a6b4200cbe97225e35e83c8808

2 files changed, 8 insertions(+), 0 deletions(-)

jump to
M .github/workflows/build-and-deploy.yml → .github/workflows/build-and-deploy.yml

@@ -190,6 +190,11 @@ content.innerHTML = DOMPurify.sanitize(html);

if (window.renderMathInElement) { window.renderMathInElement(content, { throwOnError: false, + macros: { + "\\ensuremath": "#1", + "\\sf": "\\mathsf", + "\\tt": "\\texttt" + }, delimiters: [ { left: '$$', right: '$$', display: true }, { left: '$', right: '$', display: false },
M scripts/convert-paper.sh → scripts/convert-paper.sh

@@ -31,12 +31,15 @@ # Clean residual LaTeX wrappers that are not useful in markdown output.

perl -0777 -i -pe ' s/\\hyperlink\{[^{}]*\}\{([^{}]*)\}/$1/g; s/\\hypertarget\{[^{}]*\}\{([^{}]*)\}/$1/g; + s/\\ensuremath\{/\{/g; s/\\ensuremath\{([^{}]+)\}/$1/g; s/\\detokenize\{([^{}]+)\}/$1/g; s/\{\\sf\{([^{}]+)\}\}/\\texttt{$1}/g; s/\\sf\{([^{}]+)\}/\\texttt{$1}/g; s/\{\\tt\{([^{}]+)\}\}/\\texttt{$1}/g; s/\\tt\{([^{}]+)\}/\\texttt{$1}/g; + s/\\text\{\\tiny\s*\\sf\s*([^{}]+)\}/\\mathrm{$1}/g; + s/\\text\{\\tiny\s*\\mathsf\{([^{}]+)\}\}/\\mathrm{$1}/g; s/\\xspace//g; s/\\hspace\{[^}]*\}//g; s/\\rule\{[^}]*\}\{[^}]*\}//g;