Skip to content

Commit

Permalink
Scroll overflow for long equations (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
friggog authored Nov 22, 2020
1 parent b1d69a5 commit 5498315
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

* ![Enhancement][badge-enhancement] The HTML front end now respects the user's OS-level dark theme preference (determined via the `prefers-color-scheme: dark` media query). ([#1320][github-1320], [#1456][github-1456])

## 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])
Expand Down Expand Up @@ -696,9 +700,11 @@
[github-1466]: https://github.com/JuliaDocs/Documenter.jl/issues/1466
[github-1468]: https://github.com/JuliaDocs/Documenter.jl/pull/1468
[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

Expand Down
5 changes: 5 additions & 0 deletions assets/html/scss/documenter/_patches.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions assets/html/scss/documenter/layout/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions assets/html/themes/documenter-dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions assets/html/themes/documenter-light.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,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)()
Expand Down
33 changes: 33 additions & 0 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
36 changes: 36 additions & 0 deletions test/examples/src/man/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion test/examples/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ end
end
end

@test length(doc.internal.objects) == 41
@test length(doc.internal.objects) == 42
end
end

0 comments on commit 5498315

Please sign in to comment.