summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context')
-rw-r--r--Master/texmf-dist/tex/context/third/markdown/t-markdown.tex41
1 files changed, 33 insertions, 8 deletions
diff --git a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex
index dfacdc95285..f92f89dda62 100644
--- a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex
+++ b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex
@@ -62,14 +62,39 @@
\advance\count0 by 1\relax
\ifnum\count0<256\repeat
\catcode`|=12}%
-\begingroup
- \catcode`\|=0%
- \catcode`\\=12%
- |gdef|startmarkdown{%
- |markdownReadAndConvert{\stopmarkdown}%
- {|stopmarkdown}}%
- |gdef|stopmarkdown{|markdownEnd}%
-|endgroup
+\ifx\startluacode\undefined % MkII
+ \begingroup
+ \catcode`\|=0%
+ \catcode`\\=12%
+ |gdef|startmarkdown{%
+ |markdownReadAndConvert{\stopmarkdown}%
+ {|stopmarkdown}}%
+ |gdef|stopmarkdown{%
+ |markdownEnd}%
+ |endgroup
+\else % MkIV
+ \startluacode
+ document.markdown_buffering = false
+ local function preserve_trailing_spaces(line)
+ if document.markdown_buffering then
+ line = line:gsub("[ \t][ \t]$", "\t\t")
+ end
+ return line
+ end
+ resolvers.installinputlinehandler(preserve_trailing_spaces)
+ \stopluacode
+ \begingroup
+ \catcode`\|=0%
+ \catcode`\\=12%
+ |gdef|startmarkdown{%
+ |ctxlua{document.markdown_buffering = true}%
+ |markdownReadAndConvert{\stopmarkdown}%
+ {|stopmarkdown}}%
+ |gdef|stopmarkdown{%
+ |ctxlua{document.markdown_buffering = false}%
+ |markdownEnd}%
+ |endgroup
+\fi
\def\markdownRendererLineBreakPrototype{\blank}%
\def\markdownRendererLeftBracePrototype{\textbraceleft}%
\def\markdownRendererRightBracePrototype{\textbraceright}%