git.iko.soy/typeable/pandoc
on master help sign in
RST writer: Skip spaces after display math.

Otherwise we get indentation problems, and part of the next paragraph may be rendered as part of the math.

commitde10b1653e0624d91bc9b0b96d2f84c4673c6d98 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 11 Oct 2013, 22:01 (13 years ago) parent25e43d1
1 file changed+8−2
src/Text/Pandoc/Writers/RST.hs+8−2
src/Text/Pandoc/Writers/RST.hs+8−2
@@ -296,8 +296,14 @@ blockListToRST blocks = mapM blockToRST blocks >>= return . vcat
296296
297297-- | Convert list of Pandoc inline elements to RST.
298298inlineListToRST :: [Inline] -> State WriterState Doc
299−inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat
300− where insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed
299+inlineListToRST lst =
300+ mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>= return . hcat
301+ where -- remove spaces after displaymath, as they screw up indentation:
302+ removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
303+ Math DisplayMath x : dropWhile (==Space) zs
304+ removeSpaceAfterDisplayMath (x:xs) = x : removeSpaceAfterDisplayMath xs
305+ removeSpaceAfterDisplayMath [] = []
306+ insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed
301307 insertBS (x:y:z:zs)
302308 | isComplex y && surroundComplex x z =
303309 x : y : RawInline "rst" "\\ " : insertBS (z:zs)