From c3fb1dd4ea0cecaf541061b26ff6091b2d913140 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 8 Jul 2007 16:48:54 +0000 Subject: Added --toc support to RST writer. git-svn-id: https://pandoc.googlecode.com/svn/trunk@652 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/RST.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 175d69e30..b79ce1d94 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -130,7 +130,10 @@ metaToRST opts (Meta title authors date) = do title' <- titleToRST opts title authors' <- authorsToRST authors date' <- dateToRST date - return $ title' <> authors' <> date' + let toc = if writerTableOfContents opts + then text "" $$ text ".. contents::" + else empty + return $ title' $$ authors' $$ date' $$ toc $$ text "" titleToRST :: WriterOptions -> [Inline] -> State WriterState Doc titleToRST opts [] = return empty @@ -138,17 +141,17 @@ titleToRST opts lst = do contents <- inlineListToRST opts lst let titleLength = length $ render contents let border = text (replicate titleLength '=') - return $ border <> char '\n' <> contents <> char '\n' <> border <> text "\n\n" + return $ border <> char '\n' <> contents <> char '\n' <> border <> text "\n" authorsToRST :: [String] -> State WriterState Doc authorsToRST [] = return empty authorsToRST (first:rest) = do rest' <- authorsToRST rest - return $ text ":Author: " <> text first <> char '\n' <> rest' + return $ (text ":Author: " <> text first) $$ rest' dateToRST :: String -> State WriterState Doc dateToRST [] = return empty -dateToRST str = return $ text ":Date: " <> text (escapeString str) <> char '\n' +dateToRST str = return $ text ":Date: " <> text (escapeString str) -- | Convert Pandoc block element to RST. blockToRST :: WriterOptions -- ^ Options -- cgit v1.2.3