@@ -119,9 +119,8 @@ writeRTF options doc = do
119 inlinesToRTF
119 inlinesToRTF
121 body <- blocksToRTF 0 AlignDefault blocks
121 body <- blocksToRTF 0 AlignDefault blocks
122− let isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options
122+ toc <- blocksToRTF 0 AlignDefault
123− isTOCHeader _ = False
123+ [toTableOfContents options $ filter isHeaderBlock blocks]
124− toc <- tableOfContents $ filter isTOCHeader blocks
125 let context = defField "body" body
124 let context = defField "body" body
126 $ defField "spacer" spacer
125 $ defField "spacer" spacer
127 $(if writerTableOfContents options
126 $(if writerTableOfContents options
@@ -139,20 +138,6 @@ writeRTF options doc = do
139 ('\n':_) -> body
138 ('\n':_) -> body
140 _ -> body ++ "\n"
139 _ -> body ++ "\n"
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]
149−elementToListItem :: Element -> [Block]
150−elementToListItem (Blk _) = []
151−elementToListItem (Sec _ _ _ sectext subsecs) = Plain sectext :
154− else [BulletList (map elementToListItem subsecs)]
156-- | Convert unicode characters (> 127) into rich text format representation.
141-- | Convert unicode characters (> 127) into rich text format representation.
157handleUnicode :: String -> String
142handleUnicode :: String -> String
158handleUnicode [] = []
143handleUnicode [] = []