Haddock Writer: Use proper format for latex math in haddock (#4571).
Inline math in `\(..\)`, display math in `\[..\]`, tex is now used.
Previously we'd "fake it with unicode" and fall back to tex when
that didn't work. But as of
3f50b95532
haddock supports latex math.
This commit is contained in:
parent
1b66865763
commit
822a071bb2
2 changed files with 11 additions and 13 deletions
|
@ -45,7 +45,6 @@ import Text.Pandoc.Options
|
|||
import Text.Pandoc.Pretty
|
||||
import Text.Pandoc.Shared
|
||||
import Text.Pandoc.Templates (renderTemplate')
|
||||
import Text.Pandoc.Writers.Math (texMathToInlines)
|
||||
import Text.Pandoc.Writers.Shared
|
||||
|
||||
type Notes = [[Block]]
|
||||
|
@ -250,11 +249,10 @@ inlineToHaddock _ (Code _ str) =
|
|||
return $ "@" <> text (escapeString str) <> "@"
|
||||
inlineToHaddock _ (Str str) =
|
||||
return $ text $ escapeString str
|
||||
inlineToHaddock opts (Math mt str) = do
|
||||
let adjust x = case mt of
|
||||
DisplayMath -> cr <> x <> cr
|
||||
InlineMath -> x
|
||||
adjust <$> (lift (texMathToInlines mt str) >>= inlineListToHaddock opts)
|
||||
inlineToHaddock _ (Math mt str) =
|
||||
return $ case mt of
|
||||
DisplayMath -> cr <> "\\[" <> text str <> "\\]" <> cr
|
||||
InlineMath -> "\\(" <> text str <> "\\)"
|
||||
inlineToHaddock _ il@(RawInline f str)
|
||||
| f == "haddock" = return $ text str
|
||||
| otherwise = do
|
||||
|
|
|
@ -455,14 +455,14 @@ ______________________________________________________________________________
|
|||
#latex#
|
||||
|
||||
-
|
||||
- 2 + 2 = 4
|
||||
- /x/ ∈ /y/
|
||||
- /α/ ∧ /ω/
|
||||
- 223
|
||||
- /p/-Tree
|
||||
- \(2+2=4\)
|
||||
- \(x \in y\)
|
||||
- \(\alpha \wedge \omega\)
|
||||
- \(223\)
|
||||
- \(p\)-Tree
|
||||
- Here’s some display math:
|
||||
$$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$$
|
||||
- Here’s one that has a line break in it: /α/ + /ω/ × /x/2.
|
||||
\[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}\]
|
||||
- Here’s one that has a line break in it: \(\alpha + \omega \times x^2\).
|
||||
|
||||
These shouldn’t be math:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue