diff options
| author | John MacFarlane <[email protected]> | 2025-11-02 15:24:08 +0100 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-11-02 15:37:54 +0100 |
| commit | 1edd5cde725bcb2687827cc0eb07fc924e001ff1 (patch) | |
| tree | fa13c4e6d85d85807b3b386c8bf9995dbfc38b31 /src | |
| parent | b69e9dbb810573d5f039233f8e84ee3acb2027fe (diff) | |
LaTeX writer: improve handling of math environments in tex math.
Previously the special handling added for #9711 worked only
when the math element did not contain spaces before the
math environment.
Closes #11266.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e10556cee..a0ecf687d 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1375,7 +1375,7 @@ ldfLanguages = isMathEnv :: Text -> Bool isMathEnv t = - case T.stripPrefix "\\begin{" t of + case T.stripPrefix "\\begin{" (T.dropWhile isSpaceChar t) of Nothing -> False Just t' -> T.takeWhile (/= '}') t' `elem` [ "align", "align*" @@ -1392,6 +1392,12 @@ isMathEnv t = , "eqnarray" , "displaymath" ] + where + isSpaceChar '\n' = True + isSpaceChar '\r' = True + isSpaceChar '\t' = True + isSpaceChar ' ' = True + isSpaceChar _ = False -- True if the math needs the cancel package needsCancel :: Text -> Bool |
