Skip to content

Commit

Permalink
Handle Markdown.LineBreak in LaTeXWriter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mortenpi committed Aug 23, 2022
1 parent 3968745 commit cbd7d98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
3 changes: 3 additions & 0 deletions src/Writers/LaTeXWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions test/examples/src.latex_simple/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ LaTeXEquation2(raw"""
\end{array}\right]
""")
```

## `LineBreak` node

This sentence\
should be over **multiple\
lines**.

0 comments on commit cbd7d98

Please sign in to comment.