diff --git a/CHANGELOG.md b/CHANGELOG.md index a6040d0772..8c67a2c822 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Documenter.jl changelog +## Version `v0.25.5` + +* ![Bugfix][badge-bugfix] In the HTML output, display equations that are wider than the page now get a scrollbar instead of overflowing. ([#1470][github-1470], [#1476][github-1476]) + ## Version `v0.25.4` * ![Feature][badge-feature] Documenter can now deploy from Buildkite CI to GitHub Pages with `Documenter.Buildkite`. ([#1469][github-1469]) @@ -682,9 +686,11 @@ [github-1463]: https://github.com/JuliaDocs/Documenter.jl/pull/1463 [github-1466]: https://github.com/JuliaDocs/Documenter.jl/issues/1466 [github-1469]: https://github.com/JuliaDocs/Documenter.jl/pull/1469 +[github-1470]: https://github.com/JuliaDocs/Documenter.jl/issues/1470 [github-1471]: https://github.com/JuliaDocs/Documenter.jl/pull/1471 [github-1472]: https://github.com/JuliaDocs/Documenter.jl/pull/1472 [github-1474]: https://github.com/JuliaDocs/Documenter.jl/pull/1474 +[github-1476]: https://github.com/JuliaDocs/Documenter.jl/pull/1476 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/assets/html/scss/documenter/_patches.scss b/assets/html/scss/documenter/_patches.scss index f76f736227..3bfd6a29af 100644 --- a/assets/html/scss/documenter/_patches.scss +++ b/assets/html/scss/documenter/_patches.scss @@ -66,6 +66,11 @@ right: 0; } +// fix spacing for math displays, particularly important with overflow scroll bar +.katex-display, mjx-container, .MathJax_Display { + margin: 0.5em 0 !important; +} + // Set font subpixel rendering to auto on the HTML tag html { -moz-osx-font-smoothing: auto; diff --git a/assets/html/scss/documenter/layout/_main.scss b/assets/html/scss/documenter/layout/_main.scss index 0acbcdbceb..b9a5a494a8 100644 --- a/assets/html/scss/documenter/layout/_main.scss +++ b/assets/html/scss/documenter/layout/_main.scss @@ -8,6 +8,10 @@ // Long inline words can happen, so we'll break them in case that, instead of letting // go into overflow. Most likely to happen with inline code snippets. overflow-wrap: break-word; + + .math-container { + overflow-x: auto; + } } @include desktop { diff --git a/assets/html/themes/documenter-dark.css b/assets/html/themes/documenter-dark.css index ea7d8034f1..f866234ff7 100644 --- a/assets/html/themes/documenter-dark.css +++ b/assets/html/themes/documenter-dark.css @@ -7305,11 +7305,15 @@ html.theme--documenter-dark { html.theme--documenter-dark .katex .katex-mathml { top: 0; right: 0; } + html.theme--documenter-dark .katex-display, html.theme--documenter-dark mjx-container, html.theme--documenter-dark .MathJax_Display { + margin: 0.5em 0 !important; } html.theme--documenter-dark html { -moz-osx-font-smoothing: auto; -webkit-font-smoothing: auto; } html.theme--documenter-dark #documenter .docs-main > article { overflow-wrap: break-word; } + html.theme--documenter-dark #documenter .docs-main > article .math-container { + overflow-x: auto; } @media screen and (min-width: 1056px) { html.theme--documenter-dark #documenter .docs-main { max-width: 52rem; diff --git a/assets/html/themes/documenter-light.css b/assets/html/themes/documenter-light.css index b5dbe628e2..57fdf947d7 100644 --- a/assets/html/themes/documenter-light.css +++ b/assets/html/themes/documenter-light.css @@ -7277,6 +7277,9 @@ h1:hover .docs-heading-anchor-permalink, h2:hover .docs-heading-anchor-permalink top: 0; right: 0; } +.katex-display, mjx-container, .MathJax_Display { + margin: 0.5em 0 !important; } + html { -moz-osx-font-smoothing: auto; -webkit-font-smoothing: auto; } @@ -7287,6 +7290,8 @@ html { */ #documenter .docs-main > article { overflow-wrap: break-word; } + #documenter .docs-main > article .math-container { + overflow-x: auto; } @media screen and (min-width: 1056px) { #documenter .docs-main { diff --git a/src/Writers/HTMLWriter.jl b/src/Writers/HTMLWriter.jl index f4058c6bbd..77272fe76b 100644 --- a/src/Writers/HTMLWriter.jl +++ b/src/Writers/HTMLWriter.jl @@ -1634,7 +1634,10 @@ end mdconvert(i::Markdown.Italic, parent; kwargs...) = Tag(:em)(mdconvert(i.text, i; kwargs...)) -mdconvert(m::Markdown.LaTeX, ::MDBlockContext; kwargs...) = Tag(:div)(string("\\[", m.formula, "\\]")) +function mdconvert(m::Markdown.LaTeX, ::MDBlockContext; kwargs...) + @tags p + p[".math-container"](string("\\[", m.formula, "\\]")) +end mdconvert(m::Markdown.LaTeX, parent; kwargs...) = Tag(:span)(string('$', m.formula, '$')) mdconvert(::Markdown.LineBreak, parent; kwargs...) = Tag(:br)() diff --git a/test/examples/make.jl b/test/examples/make.jl index 0a1c7b3a20..13becda892 100644 --- a/test/examples/make.jl +++ b/test/examples/make.jl @@ -37,6 +37,39 @@ module Mod [`func(x)`](@ref) """ mutable struct T end + + @doc raw""" + Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + + Display equation: + + ```math + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + ``` + + !!! note "Long equations in admonitions" + + Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + + Display equation: + + ```math + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + ``` + + Long equations in footnotes.[^longeq-footnote] + + [^longeq-footnote]: + + Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + + Display equation: + + ```math + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + ``` + """ + function long_equations_in_docstrings end end "`AutoDocs` module." diff --git a/test/examples/src/man/style.md b/test/examples/src/man/style.md index d215087f25..7b1d9ab649 100644 --- a/test/examples/src/man/style.md +++ b/test/examples/src/man/style.md @@ -83,3 +83,39 @@ This sentence has a footnote.[^5] x = randn(LogDensityProblems.dimension(∇P)) @benchmark LogDensityProblems.logdensity_and_gradient($∇P, $x) ``` + +## Math + +Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + +Display equation: + +```math +\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} +``` + +!!! note "Long equations in admonitions" + + Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + + Display equation: + + ```math + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + ``` + +Long equations in footnotes.[^longeq] + +[^longeq]: + + Inline: ``\frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2}`` + + Display equation: + + ```math + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + \frac{1+2+3+4+5+6}{\sigma^2} + ``` + +```@docs +Mod.long_equations_in_docstrings +``` diff --git a/test/examples/tests.jl b/test/examples/tests.jl index c06543c467..e429bbc709 100644 --- a/test/examples/tests.jl +++ b/test/examples/tests.jl @@ -150,6 +150,6 @@ end end end - @test length(doc.internal.objects) == 41 + @test length(doc.internal.objects) == 42 end end