Witiko / markdown

:notebook_with_decorative_cover: A package for converting and rendering markdown documents in TeX
http://ctan.org/pkg/markdown
LaTeX Project Public License v1.3c
327 stars 31 forks source link

With the `hybrid` option enabled, a backslash at the end of a document breaks the conversion of the last paragraph #502

Open Witiko opened 1 week ago

Witiko commented 1 week ago

With the hybrid option disabled, a backslash (\) at the end of a document produces the command \markdownRendererBackslash, as expected:

$ docker run --rm -i witiko/markdown markdown-cli hybrid=false <<< 'foo \'$'\n''bar \'
\markdownRendererDocumentBegin
foo\markdownRendererHardLineBreak
{}bar \markdownRendererBackslash{}\markdownRendererDocumentEnd
$ docker run --rm -i witiko/markdown markdown-cli hybrid=false <<< 'foo'$'\n\n''bar \'
\markdownRendererDocumentBegin
foo\markdownRendererParagraphSeparator
{}bar \markdownRendererBackslash{}\markdownRendererDocumentEnd

With the hybrid option enabled, a backslash (\) at the end of a document should produce a literal backslash:

\markdownRendererDocumentBegin
foo\markdownRendererHardLineBreak
{}bar \\markdownRendererDocumentEnd
\markdownRendererDocumentBegin
foo\markdownRendererParagraphSeparator
{}bar \\markdownRendererDocumentEnd

However, it produces the following output instead:

$ docker run --rm -i witiko/markdown markdown-cli hybrid=true  <<< 'foo \'$'\n''bar \'
\markdownRendererDocumentBegin
nil\markdownRendererDocumentEnd
$ docker run --rm -i witiko/markdown markdown-cli hybrid=true  <<< 'foo'$'\n\n''bar \'
\markdownRendererDocumentBegin
foo\markdownRendererDocumentEnd

As you can see, with the hybrid option enabled, a backslash at the end of a document breaks the conversion of the whole last paragraph, potentially replacing the paragraph with the text nil.