aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2019-11-22 16:57:24 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-22 07:57:24 -0800
commitd948e13feaf4d2db90a8ab452a65e5ce34028804 (patch)
tree21d6db33e1aa05da463b54860a16230d7263eb56 /src/Text
parent138d0b1b3e7105ae28f05016aaf9e5784aa5030e (diff)
downloadpandoc-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')
-rw-r--r--src/Text/Pandoc/Writers/Jira.hs27
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
- '&' -> "&amp;"
- '<' -> "&lt;"
- '>' -> "&gt;"
- '"' -> "&quot;"
- '*' -> "&ast;"
- '_' -> "&lowbar;"
- '@' -> "&commat;"
- '+' -> "&plus;"
- '-' -> "&hyphen;"
- '|' -> "&vert;"
- '{' -> "\\{"
- '\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