diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c67a89f7..ba6ffdef0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ * ![Bugfix][badge-bugfix] Doctests now correctly handle the case when the repository has been checked out with `CRLF` line endings (which can happen on Windows with `core.autocrlf=true`). ([#1516][github-1516], [#1519][github-1519], [#1520][github-1520]) +* ![Bugfix][badge-bugfix] Multiline equations are now correctly handled in at-block outputs. ([#1518][github-1518]) + ## Version `v0.26.1` * ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497]) @@ -740,6 +742,7 @@ [github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 [github-1516]: https://github.com/JuliaDocs/Documenter.jl/issues/1516 +[github-1518]: https://github.com/JuliaDocs/Documenter.jl/pull/1518 [github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519 [github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520 diff --git a/src/Writers/HTMLWriter.jl b/src/Writers/HTMLWriter.jl index b37958023f..427e1032ef 100644 --- a/src/Writers/HTMLWriter.jl +++ b/src/Writers/HTMLWriter.jl @@ -1762,9 +1762,9 @@ function mdconvert(d::Dict{MIME,Any}, parent; kwargs...) # unwrap it first, since when we output Markdown.LaTeX objects we put the correct # delimiters around it anyway. latex = d[MIME"text/latex"()] - equation = false - m_bracket = match(r"\s*\\\[(.*)\\\]\s*", latex) - m_dollars = match(r"\s*\$\$(.*)\$\$\s*", latex) + # Make sure to match multiline strings! + m_bracket = match(r"\s*\\\[(.*)\\\]\s*"s, latex) + m_dollars = match(r"\s*\$\$(.*)\$\$\s*"s, latex) if m_bracket === nothing && m_dollars === nothing out = Utilities.mdparse(latex; mode = :single) else diff --git a/test/examples/src/man/tutorial.md b/test/examples/src/man/tutorial.md index c117ae86be..01c0bceaaf 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -433,3 +433,39 @@ or wrapped in `$$ ... $$`: ```@example showablelatex LaTeXEquation(raw"$$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$$") ``` + +--- + +Extra tests for handling multi-line equations ([#1518](https://github.com/JuliaDocs/Documenter.jl/pull/1518)): + + +```@example showablelatex +LaTeXEquation(raw""" +\[ + \left[ + \begin{array}{rr} + x & 2x + \end{array} + \right] +\] +""") +``` + +```@example showablelatex +LaTeXEquation(raw"""$$ +\begin{bmatrix} + 1 & 2 \\ + 3 & 4 +\end{bmatrix} +$$""") +``` + +Without `raw""` strings we have to double-escape our `\` and `$`: + +```@example showablelatex +LaTeXEquation("\\[\\left[\\begin{array}{rr} x & 2x \\\\ \n y & y \\end{array}\\right]\\]") +``` + +```@example showablelatex +LaTeXEquation("\$\$\\begin{bmatrix} 1 & 2 \\\\ \n 3 & 4 \\end{bmatrix}\$\$") +```