From 9fa2d0892e37f0f1e4cbc397603ce0bcfc135eca Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 2 Oct 2021 08:21:46 -0700 Subject: [PATCH] Restore RST writer. --- src/Text/Pandoc/Writers/RST.hs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 4b384f9a2..1fc80839d 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -51,9 +51,6 @@ type RST = StateT WriterState -- | Convert Pandoc to RST. writeRST :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeRST opts document = do - undefined - -{- let st = WriterState { stNotes = [], stLinks = [], stImages = [], stHasMath = False, stHasRawTeX = False, stOptions = opts, @@ -448,9 +445,11 @@ transformInlines = insertBS . hasContents (Link _ [] ("", "")) = False hasContents (Image _ [] ("", "")) = False hasContents _ = True + dropInitialSpace (Str t : xs) = Str (T.dropWhile (==' ') t) : xs + dropInitialSpace xs = xs -- remove spaces after displaymath, as they screw up indentation: removeSpaceAfterDisplayMath (Math DisplayMath x : zs) = - Math DisplayMath x : dropWhile (==Space) zs + Math DisplayMath x : dropInitialSpace zs removeSpaceAfterDisplayMath (x:xs) = x : removeSpaceAfterDisplayMath xs removeSpaceAfterDisplayMath [] = [] insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed @@ -508,8 +507,6 @@ transformInlines = insertBS . isComplex (Span _ (x:_)) = isComplex x isComplex _ = False --} - -- | Flattens nested inlines. Extracts nested inlines and goes through -- them either collapsing them in the outer inline container or -- pulling them out of it @@ -592,7 +589,6 @@ setInlineChildren (Image a _ t) i = Image a i t setInlineChildren (Span a _) i = Span a i setInlineChildren leaf _ = leaf -{- inlineListToRST :: PandocMonad m => [Inline] -> RST m (Doc Text) inlineListToRST = writeInlines . walk transformInlines @@ -783,4 +779,3 @@ simpleTable opts blocksToDoc headers rows = do else hline $$ toRow headerDocs let bdy = vcat $ map toRow rowDocs return $ hdr $$ hline $$ bdy $$ hline --}