aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-04-17 22:42:21 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-04-17 22:42:21 -0700
commit9a809d4d01f1a9cba4401e98d95cccf8a0ec7e75 (patch)
treeef09a4a428fb512e7df44142fd56892496f63fdd /src/Text/Pandoc
parent0d2b8e3fe1d6a27aac082be7711b7156783b3051 (diff)
downloadpandoc-9a809d4d01f1a9cba4401e98d95cccf8a0ec7e75.tar.gz
Markdown writer: avoid unnecessary escapes before intraword `_`
when `intraword_underscores` extension is enabled. Closes #6296.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 7a11e3c16..fb9888b24 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -313,7 +313,12 @@ escapeText opts =
case cs of
'.':'.':rest -> '\\':'.':'.':'.':go rest
_ -> '.':go cs
- _ -> c : go cs
+ _ -> case cs of
+ '_':x:xs
+ | isEnabled Ext_intraword_underscores opts
+ , isAlphaNum c
+ , isAlphaNum x -> c : '_' : x : go xs
+ _ -> c : go cs
attrsToMarkdown :: Attr -> Doc Text
attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]