diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-07-30 13:45:22 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-07-30 13:45:22 -0700 |
commit | b8afec05e0ce85ab811bf55d4948be768ad363e2 (patch) | |
tree | 987e8334e08d2415bf4707bed7e1ec618f531812 /src/Text/Pandoc/Writers | |
parent | 8cbc28415ef7246e9eb5b74d8958f1ab0dc01d4d (diff) | |
download | pandoc-b8afec05e0ce85ab811bf55d4948be768ad363e2.tar.gz |
Markdown writer: better escaping of `<` and `>`.
If `all_symbols_escapable` is set, we backslash escape these.
Otherwise we use entities as before.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 1e0d8bde2..837c177f1 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -280,8 +280,12 @@ escapeString :: WriterOptions -> String -> String escapeString _ [] = [] escapeString opts (c:cs) = case c of - '<' -> "<" ++ escapeString opts cs - '>' -> ">" ++ escapeString opts cs + '<' | isEnabled Ext_all_symbols_escapable opts -> + '\\' : '<' : escapeString opts cs + | otherwise -> "<" ++ escapeString opts cs + '>' | isEnabled Ext_all_symbols_escapable opts -> + '\\' : '>' : escapeString opts cs + | otherwise -> ">" ++ escapeString opts cs _ | c `elem` ['\\','`','*','_','[',']','#'] -> '\\':c:escapeString opts cs '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs |