diff --git a/markdown.dtx b/markdown.dtx index 81238c2cb..bd2885d80 100644 --- a/markdown.dtx +++ b/markdown.dtx @@ -33405,9 +33405,11 @@ end % \end{markdown} % \begin{macrocode} \startluacode - document.markdown_buffering = false + document.markdown_preserve_trailing_spaces = true + document.markdown_is_buffering = false local function preserve_trailing_spaces(line) - if document.markdown_buffering then + if document.markdown_is_buffering and + document.markdown_preserve_trailing_spaces then line = line:gsub("[ \t][ \t]$", "\t\t") end return line @@ -33418,11 +33420,11 @@ end \catcode`\|=0% \catcode`\\=12% |gdef|startmarkdown{% - |ctxlua{document.markdown_buffering = true}% + |ctxlua{document.markdown_is_buffering = true}% |markdownReadAndConvert{\stopmarkdown}% {|stopmarkdown}}% |gdef|stopmarkdown{% - |ctxlua{document.markdown_buffering = false}% + |ctxlua{document.markdown_is_buffering = false}% |markdownEnd}% |endgroup % \end{macrocode} diff --git a/tests/templates/context-mkiv/verbatim/body.tex.m4 b/tests/templates/context-mkiv/verbatim/body.tex.m4 index 73cf020d7..ac90f3781 100644 --- a/tests/templates/context-mkiv/verbatim/body.tex.m4 +++ b/tests/templates/context-mkiv/verbatim/body.tex.m4 @@ -4,6 +4,8 @@ % Prevent the folding of characters into a single space token in logs. \catcode"09=12% Tabs (U+0009) \catcode"20=12% Spaces (U+0020) +% Do not preserve trailing spaces in input buffer for parity with other TeX formats. +\ctxlua{document.markdown_preserve_trailing_spaces = false} % Disable active characters of the TeX engine. \catcode"7E=12% Tildes (U+007E) \catcode"7C=12% Pipes (U+007C)