@@ -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)