diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-01-14 15:10:13 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-01-14 15:11:11 -0800 |
commit | 615a99c2c20782daae5de38854025e2d40d85f29 (patch) | |
tree | 20c5948daabb6e241633c7536c22109e57969826 /src | |
parent | d9584d73f94501787026c57b77d217e51f21505d (diff) | |
download | pandoc-615a99c2c20782daae5de38854025e2d40d85f29.tar.gz |
RST reader: add aligned environment when needed in math.
rst2latex.py uses an align* environment for math in
`.. math::` blocks, so this math may contain line breaks.
If it does, we put the math in an `aligned` environment
to simulate rst2latex.py's behavior.
Closes #4254.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index ba5a24f8f..49cc3018c 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -972,11 +972,16 @@ extractCaption = do legend <- optional blanklines >> (mconcat <$> many block) return (capt,legend) --- divide string by blanklines +-- divide string by blanklines, and surround with +-- \begin{aligned}...\end{aligned} if needed. toChunks :: String -> [String] toChunks = dropWhile null - . map (trim . unlines) + . map (addAligned . trim . unlines) . splitBy (all (`elem` (" \t" :: String))) . lines + -- we put this in an aligned environment if it contains \\, see #4254 + where addAligned s = if "\\\\" `isInfixOf` s + then "\\begin{aligned}\n" ++ s ++ "\n\\end{aligned}" + else s codeblock :: [String] -> Maybe String -> String -> String -> RSTParser m Blocks codeblock classes numberLines lang body = |