diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2019-11-22 16:57:24 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-11-22 07:57:24 -0800 |
commit | d948e13feaf4d2db90a8ab452a65e5ce34028804 (patch) | |
tree | 21d6db33e1aa05da463b54860a16230d7263eb56 /src/Text/Pandoc/Writers | |
parent | 138d0b1b3e7105ae28f05016aaf9e5784aa5030e (diff) | |
download | pandoc-d948e13feaf4d2db90a8ab452a65e5ce34028804.tar.gz |
Jira writer: improve escaping of special chars (#5925)
Backslash-escaping is used instead of HTML entities, as escaped
characters are easier to read this way. Furthermore, Confluence, which
seems to use a subset of Jira markup, seems to get confused by HTML
entities.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Jira.hs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs index d26dae4c7..2a2470209 100644 --- a/src/Text/Pandoc/Writers/Jira.hs +++ b/src/Text/Pandoc/Writers/Jira.hs @@ -69,23 +69,14 @@ pandocToJira opts (Pandoc meta blocks) = do -- | Escape one character as needed for Jira. escapeCharForJira :: Char -> Text -escapeCharForJira c = case c of - '&' -> "&" - '<' -> "<" - '>' -> ">" - '"' -> """ - '*' -> "*" - '_' -> "_" - '@' -> "@" - '+' -> "+" - '-' -> "‐" - '|' -> "|" - '{' -> "\\{" - '\x2014' -> " -- " - '\x2013' -> " - " - '\x2019' -> "'" - '\x2026' -> "..." - _ -> T.singleton c +escapeCharForJira c = + let specialChars = "_*-+~^|!{}[]" :: String + in case c of + '\x2013' -> " -- " + '\x2014' -> " --- " + '\x2026' -> "..." + _ | c `elem` specialChars -> T.cons '\\' (T.singleton c) + _ -> T.singleton c -- | Escape string as needed for Jira. escapeStringForJira :: Text -> Text @@ -155,7 +146,7 @@ blockToJira opts (BlockQuote [p@(Para _)]) = do blockToJira opts (BlockQuote blocks) = do contents <- blockListToJira opts blocks - appendNewlineUnlessInList . T.intercalate "\n" $ + appendNewlineUnlessInList . T.unlines $ [ "{quote}", contents, "{quote}"] blockToJira opts (Table _caption _aligns _widths headers rows) = do |