git.iko.soy/typeable/pandoc
on master help sign in
RTF writer: use toTableOfContents from T.P.W.Shared.
commit571fede73252138891bbf7eefddbd47947f7eb16 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 4 Jan 2019, 21:27 (8 years ago) parentc4c3fca
1 file changed+2−17
src/Text/Pandoc/Writers/RTF.hs+2−17
src/Text/Pandoc/Writers/RTF.hs+2−17
@@ -119,9 +119,8 @@ writeRTF options doc = do
119119 inlinesToRTF
120120 meta'
121121 body <- blocksToRTF 0 AlignDefault blocks
122− let isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options
123− isTOCHeader _ = False
124− toc <- tableOfContents $ filter isTOCHeader blocks
122+ toc <- blocksToRTF 0 AlignDefault
123+ [toTableOfContents options $ filter isHeaderBlock blocks]
125124 let context = defField "body" body
126125 $ defField "spacer" spacer
127126 $(if writerTableOfContents options
@@ -139,20 +138,6 @@ writeRTF options doc = do
139138 ('\n':_) -> body
140139 _ -> body ++ "\n"
141140
142−-- | Construct table of contents from list of header blocks.
143−tableOfContents :: PandocMonad m => [Block] -> m String
144−tableOfContents headers = do
145− let contents = map elementToListItem $ hierarchicalize headers
146− blocksToRTF 0 AlignDefault
147− [Header 1 nullAttr [Str "Contents"], BulletList contents]
148−
149−elementToListItem :: Element -> [Block]
150−elementToListItem (Blk _) = []
151−elementToListItem (Sec _ _ _ sectext subsecs) = Plain sectext :
152− if null subsecs
153− then []
154− else [BulletList (map elementToListItem subsecs)]
155−
156141-- | Convert unicode characters (> 127) into rich text format representation.
157142handleUnicode :: String -> String
158143handleUnicode [] = []