From 91c4e3fb3a5d9e86e5fb513bb65da89d4b061b08 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sun, 3 Apr 2022 11:42:42 -0700 Subject: [PATCH] fix: multiline code block #87 --- content/notes/CJK + Latex Support (测试).md | 5 ++--- layouts/partials/textprocessing.html | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/content/notes/CJK + Latex Support (测试).md b/content/notes/CJK + Latex Support (测试).md index 8b4a741da..4b89f7512 100644 --- a/content/notes/CJK + Latex Support (测试).md +++ b/content/notes/CJK + Latex Support (测试).md @@ -23,8 +23,7 @@ Aligned equations work quite well: $$ \begin{aligned} -a &= b + c \\ - &= e + f \\ +a &= b + c \\ &= e + f \\ \end{aligned} $$ @@ -32,7 +31,7 @@ And matrices $$ \begin{bmatrix} -1 & 2 & 3\\ +1 & 2 & 3 \\ a & b & c \end{bmatrix} $$ diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html index 8e4a794f9..008d16398 100644 --- a/layouts/partials/textprocessing.html +++ b/layouts/partials/textprocessing.html @@ -5,7 +5,11 @@ {{ $content = replace $content "->" "→" }} {{/* Escape slashes for Latex to fix line breaks */}} -{{ $content = replaceRE "\\\\ *\n" "\\\\" $content }} +{{$latex := findRE "\\$\\$([^\\$]+)\\$\\$" $content}} +{{range $latex}} + {{$fixed := replaceRE "\\\\(?: +|\\n)" "\\\\" .}} + {{$content = replace $content . $fixed}} +{{end}} {{/* Wikilinks */}} {{$wikilinks := $content | findRE "\\[\\[[^\\[\\]\\|]*(?:\\|[^\\[\\]]*)?\\]\\]" }}