aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/XML.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/XML.hs')
-rw-r--r--src/Text/Pandoc/XML.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
index 31279c3bb..3f684f728 100644
--- a/src/Text/Pandoc/XML.hs
+++ b/src/Text/Pandoc/XML.hs
@@ -64,11 +64,18 @@ escapeCharForXML x = case x of
escapeStringForXML :: String -> String
escapeStringForXML = concatMap escapeCharForXML
+-- | Escape newline characters as 

+escapeNls :: String -> String
+escapeNls (x:xs)
+ | x == '\n' = "
" ++ escapeNls xs
+ | otherwise = x : escapeNls xs
+escapeNls [] = []
+
-- | Return a text object with a string of formatted XML attributes.
attributeList :: [(String, String)] -> Doc
attributeList = hcat . map
(\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++
- escapeStringForXML b ++ "\""))
+ escapeNls (escapeStringForXML b) ++ "\""))
-- | Put the supplied contents between start and end tags of tagType,
-- with specified attributes and (if specified) indentation.