Skip to content

Commit

Permalink
Fix multiline display equations in HTML (#1518)
Browse files Browse the repository at this point in the history
(cherry picked from commit 93e253a)
  • Loading branch information
odow authored and mortenpi committed Feb 9, 2021
1 parent 7bc9ba8 commit 313cad4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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])
Expand Down Expand Up @@ -733,6 +735,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

Expand Down
6 changes: 3 additions & 3 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions test/examples/src/man/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}\$\$")
```

0 comments on commit 313cad4

Please sign in to comment.