@@ -37,9 +37,9 @@ import Data.Char ( ord, isDigit )
37-- | Convert Pandoc to a string in rich text format.
37-- | Convert Pandoc to a string in rich text format.
38writeRTF :: WriterOptions -> Pandoc -> String
38writeRTF :: WriterOptions -> Pandoc -> String
39writeRTF options (Pandoc meta blocks) =
39writeRTF options (Pandoc meta blocks) =
40− let head = if writerStandalone options
40+ let head' = if writerStandalone options
41− then rtfHeader (writerHeader options) meta
41+ then rtfHeader (writerHeader options) meta
43 toc = if writerTableOfContents options
43 toc = if writerTableOfContents options
44 then tableOfContents $ filter isHeaderBlock blocks
44 then tableOfContents $ filter isHeaderBlock blocks
@@ -47,7 +47,7 @@ writeRTF options (Pandoc meta blocks) =
47 body = writerIncludeBefore options ++
47 body = writerIncludeBefore options ++
48 concatMap (blockToRTF 0 AlignDefault) blocks ++
48 concatMap (blockToRTF 0 AlignDefault) blocks ++
49 writerIncludeAfter options
49 writerIncludeAfter options
50− in head ++ toc ++ body ++ foot
50+ in head' ++ toc ++ body ++ foot
52-- | Construct table of contents from list of header blocks.
52-- | Construct table of contents from list of header blocks.
53tableOfContents :: [Block] -> String
53tableOfContents :: [Block] -> String
@@ -84,10 +84,6 @@ stringToRTF = handleUnicode . escapeSpecial
84codeStringToRTF :: String -> String
84codeStringToRTF :: String -> String
85codeStringToRTF str = joinWithSep "\\line\n" $ lines (stringToRTF str)
85codeStringToRTF str = joinWithSep "\\line\n" $ lines (stringToRTF str)
87−-- | Deal with raw LaTeX.
88−latexToRTF :: String -> String
89−latexToRTF str = "{\\cf1 " ++ (stringToRTF str) ++ "\\cf0 }"
91-- | Make a paragraph with first-line indent, block indent, and space after.
87-- | Make a paragraph with first-line indent, block indent, and space after.
92rtfParSpaced :: Int -- ^ space after (in twips)
88rtfParSpaced :: Int -- ^ space after (in twips)
93 -> Int -- ^ block indent (in twips)
89 -> Int -- ^ block indent (in twips)
@@ -122,22 +118,25 @@ rtfCompact :: Int -- ^ block indent (in twips)
122rtfCompact = rtfParSpaced 0
118rtfCompact = rtfParSpaced 0
124-- number of twips to indent
120-- number of twips to indent
121+indentIncrement :: Int
125indentIncrement = 720
122indentIncrement = 720
126listIncrement = 360
125listIncrement = 360
128-- | Returns appropriate bullet list marker for indent level.
127-- | Returns appropriate bullet list marker for indent level.
129bulletMarker :: Int -> String
128bulletMarker :: Int -> String
130bulletMarker indent = case indent `mod` 720 of
129bulletMarker indent = case indent `mod` 720 of
131− 0 -> "\\bullet "
130+ 0 -> "\\bullet "
132− otherwise -> "\\endash "
131+ _ -> "\\endash "
134-- | Returns appropriate (list of) ordered list markers for indent level.
133-- | Returns appropriate (list of) ordered list markers for indent level.
135orderedMarkers :: Int -> ListAttributes -> [String]
134orderedMarkers :: Int -> ListAttributes -> [String]
136orderedMarkers indent (start, style, delim) =
135orderedMarkers indent (start, style, delim) =
137 if style == DefaultStyle && delim == DefaultDelim
136 if style == DefaultStyle && delim == DefaultDelim
138 then case indent `mod` 720 of
137 then case indent `mod` 720 of
139− 0 -> orderedListMarkers (start, Decimal, Period)
138+ 0 -> orderedListMarkers (start, Decimal, Period)
140− otherwise -> orderedListMarkers (start, LowerAlpha, Period)
139+ _ -> orderedListMarkers (start, LowerAlpha, Period)
141 else orderedListMarkers (start, style, delim)
140 else orderedListMarkers (start, style, delim)
143-- | Returns RTF header.
142-- | Returns RTF header.
@@ -175,7 +174,7 @@ blockToRTF indent alignment (BlockQuote lst) =
175 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
174 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
176blockToRTF indent _ (CodeBlock _ str) =
175blockToRTF indent _ (CodeBlock _ str) =
177 rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
176 rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
178−blockToRTF _ _ (RawHtml str) = ""
177+blockToRTF _ _ (RawHtml _) = ""
179blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
178blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
180 concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
179 concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
181blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
180blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
@@ -238,7 +237,7 @@ listItemToRTF alignment indent marker list =
238 listMarker ++ dropWhile isDigit xs
237 listMarker ++ dropWhile isDigit xs
239 insertListMarker (x:xs) =
238 insertListMarker (x:xs) =
240 x : insertListMarker xs
239 x : insertListMarker xs
241− insertListmarker [] = []
240+ insertListMarker [] = []
242 -- insert the list marker into the (processed) first block
241 -- insert the list marker into the (processed) first block
243 in insertListMarker first ++ concat rest
242 in insertListMarker first ++ concat rest
@@ -276,14 +275,14 @@ inlineToRTF EnDash = "\\u8211-"
276inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
275inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
277inlineToRTF (Str str) = stringToRTF str
276inlineToRTF (Str str) = stringToRTF str
278inlineToRTF (Math str) = inlineListToRTF $ readTeXMath str
277inlineToRTF (Math str) = inlineListToRTF $ readTeXMath str
279−inlineToRTF (TeX str) = ""
278+inlineToRTF (TeX _) = ""
280−inlineToRTF (HtmlInline str) = ""
279+inlineToRTF (HtmlInline _) = ""
281inlineToRTF (LineBreak) = "\\line "
280inlineToRTF (LineBreak) = "\\line "
282inlineToRTF Space = " "
281inlineToRTF Space = " "
283−inlineToRTF (Link text (src, tit)) =
282+inlineToRTF (Link text (src, _)) =
284 "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++
283 "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++
285 "\"}}{\\fldrslt{\\ul\n" ++ (inlineListToRTF text) ++ "\n}}}\n"
284 "\"}}{\\fldrslt{\\ul\n" ++ (inlineListToRTF text) ++ "\n}}}\n"
286−inlineToRTF (Image alternate (source, tit)) =
285+inlineToRTF (Image _ (source, _)) =
287 "{\\cf1 [image: " ++ source ++ "]\\cf0}"
286 "{\\cf1 [image: " ++ source ++ "]\\cf0}"
288inlineToRTF (Note contents) =
287inlineToRTF (Note contents) =
289 "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++
288 "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++