aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/RTF.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-01-04 21:27:49 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-01-04 21:27:49 -0800
commit571fede73252138891bbf7eefddbd47947f7eb16 (patch)
tree350a0dd8cbc293a97b17f7f5c144f320104ee1f3 /src/Text/Pandoc/Writers/RTF.hs
parentc4c3fca50009ef5d8b3b34aaca64007ebe70f0a8 (diff)
downloadpandoc-571fede73252138891bbf7eefddbd47947f7eb16.tar.gz
RTF writer: use toTableOfContents from T.P.W.Shared.
Diffstat (limited to 'src/Text/Pandoc/Writers/RTF.hs')
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index 99f343163..913646732 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -119,9 +119,8 @@ writeRTF options doc = do
inlinesToRTF
meta'
body <- blocksToRTF 0 AlignDefault blocks
- let isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options
- isTOCHeader _ = False
- toc <- tableOfContents $ filter isTOCHeader blocks
+ toc <- blocksToRTF 0 AlignDefault
+ [toTableOfContents options $ filter isHeaderBlock blocks]
let context = defField "body" body
$ defField "spacer" spacer
$(if writerTableOfContents options
@@ -139,20 +138,6 @@ writeRTF options doc = do
('\n':_) -> body
_ -> body ++ "\n"
--- | Construct table of contents from list of header blocks.
-tableOfContents :: PandocMonad m => [Block] -> m String
-tableOfContents headers = do
- let contents = map elementToListItem $ hierarchicalize headers
- blocksToRTF 0 AlignDefault
- [Header 1 nullAttr [Str "Contents"], BulletList contents]
-
-elementToListItem :: Element -> [Block]
-elementToListItem (Blk _) = []
-elementToListItem (Sec _ _ _ sectext subsecs) = Plain sectext :
- if null subsecs
- then []
- else [BulletList (map elementToListItem subsecs)]
-
-- | Convert unicode characters (> 127) into rich text format representation.
handleUnicode :: String -> String
handleUnicode [] = []