From cbd7d987fd4f57cec4f1ec284895991c1db9b6a7 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Fri, 19 Aug 2022 18:57:07 +1200 Subject: [PATCH] Handle Markdown.LineBreak in LaTeXWriter Currently LaTeXWriter throws a MethodError when there are LineBreak nodes in the Markdown AST (i.e. hard linebreak syntax, with \ at EOL). This patch makes sure we write out \\ in those cases. --- CHANGELOG.md | 1 + src/Writers/LaTeXWriter.jl | 3 +++ test/examples/src.latex_simple/index.md | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a0efb859..5ad93ca867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ ## Version `v0.27.23` * ![Enhancement][badge-enhancement] The `native` and `docker` PDF builds now run with the `-interaction=batchmode` (instead of `nonstopmode`) and `-halt-on-error` options to make the LaTeX error logs more readable and to fail the build early. ([#1908][github-1908]) +* ![Bugfix][badge-bugfix] The PDF/LaTeX output now handles hard Markdown line breaks (i.e. `Markdown.LineBreak` nodes). ([#1908][github-1908]) ## Version `v0.27.22` diff --git a/src/Writers/LaTeXWriter.jl b/src/Writers/LaTeXWriter.jl index 13cd337e16..39cdf3fc51 100644 --- a/src/Writers/LaTeXWriter.jl +++ b/src/Writers/LaTeXWriter.jl @@ -701,6 +701,9 @@ function latexinline(io, hr::Markdown.HorizontalRule) _println(io, "\\rule{\\textwidth}{1pt}}") end +function latexinline(io, hr::Markdown.LineBreak) + _println(io, "\\\\") +end # Metadata Nodes get dropped from the final output for every format but are needed throughout # rest of the build and so we just leave them in place and print a blank line in their place. diff --git a/test/examples/src.latex_simple/index.md b/test/examples/src.latex_simple/index.md index fe88160b6c..e826523e9b 100644 --- a/test/examples/src.latex_simple/index.md +++ b/test/examples/src.latex_simple/index.md @@ -121,3 +121,9 @@ LaTeXEquation2(raw""" \end{array}\right] """) ``` + +## `LineBreak` node + +This sentence\ +should be over **multiple\ +lines**.