diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-08 16:48:54 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-08 16:48:54 +0000 |
commit | c3fb1dd4ea0cecaf541061b26ff6091b2d913140 (patch) | |
tree | 733b558d2aa9b06d1441f658b2ee5c0022d3e93d /src/Text | |
parent | 369a57e3395616252a357c4964c1df680c1ca2ac (diff) | |
download | pandoc-c3fb1dd4ea0cecaf541061b26ff6091b2d913140.tar.gz |
Added --toc support to RST writer.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@652 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 11 |
1 files changed, 7 insertions, 4 deletions
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 |