From 62f1d6a295f6ca193cef9e74080ce1208d3594e9 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 4 Feb 2021 07:05:02 +1300 Subject: [PATCH 1/4] Fix multiline display equations in HTML --- src/Writers/HTMLWriter.jl | 6 +++--- test/examples/src/man/tutorial.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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..aedb64672b 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -425,11 +425,11 @@ LaTeXEquation(raw"Foo $x^2$ bar.") Documenter also supports having the LaTeX text being already wrapped in `\[ ... \]`: ```@example showablelatex -LaTeXEquation(raw"\[\left[ \begin{array}{rr}x&2 x\end{array}\right]\]") +LaTeXEquation(raw"\[\left[ \begin{array}{rr}x&2 x\\\ny & y\end{array}\right]\]") ``` or wrapped in `$$ ... $$`: ```@example showablelatex -LaTeXEquation(raw"$$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$$") +LaTeXEquation(raw"$$\begin{bmatrix} 1 & 2 \\\n 3 & 4 \end{bmatrix}$$") ``` From 76762e7cbadb8e464645c3f2f9dcc7b9be377d84 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 5 Feb 2021 12:06:50 +1300 Subject: [PATCH 2/4] Update tutorial.md --- test/examples/src/man/tutorial.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/examples/src/man/tutorial.md b/test/examples/src/man/tutorial.md index aedb64672b..17458410c4 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -425,11 +425,12 @@ LaTeXEquation(raw"Foo $x^2$ bar.") Documenter also supports having the LaTeX text being already wrapped in `\[ ... \]`: ```@example showablelatex -LaTeXEquation(raw"\[\left[ \begin{array}{rr}x&2 x\\\ny & y\end{array}\right]\]") +LaTeXEquation("\\[\\left[\\begin{array}{rr} x & 2x \\\\ \n y & y \\end{array}\\right]\\]") ``` or wrapped in `$$ ... $$`: ```@example showablelatex -LaTeXEquation(raw"$$\begin{bmatrix} 1 & 2 \\\n 3 & 4 \end{bmatrix}$$") +LaTeXEquation("\$\$\\begin{bmatrix} 1 & 2 \\\\ \n 3 & 4 \\end{bmatrix}\$\$") ``` +although note how we have to double-escape our `\` and `$`. From a61cede8fa92492244f9682515698e6c1c93b1a1 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Tue, 9 Feb 2021 19:27:51 +1300 Subject: [PATCH 3/4] Keep old tests --- test/examples/src/man/tutorial.md | 39 +++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/test/examples/src/man/tutorial.md b/test/examples/src/man/tutorial.md index 17458410c4..01c0bceaaf 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -425,12 +425,47 @@ LaTeXEquation(raw"Foo $x^2$ bar.") Documenter also supports having the LaTeX text being already wrapped in `\[ ... \]`: ```@example showablelatex -LaTeXEquation("\\[\\left[\\begin{array}{rr} x & 2x \\\\ \n y & y \\end{array}\\right]\\]") +LaTeXEquation(raw"\[\left[ \begin{array}{rr}x&2 x\end{array}\right]\]") ``` 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}\$\$") ``` -although note how we have to double-escape our `\` and `$`. From 947b5914d1a9183fd813cd43be29daf70154d3b4 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Tue, 9 Feb 2021 19:31:35 +1300 Subject: [PATCH 4/4] Add CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) 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