git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: avoid unnecessary escapes before intraword `_`
9a809d4John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+6−1
@@ -313,7 +313,12 @@ escapeText opts =
313 case cs of
313 case cs of
314 '.':'.':rest -> '\\':'.':'.':'.':go rest
314 '.':'.':rest -> '\\':'.':'.':'.':go rest
315 _ -> '.':go cs
315 _ -> '.':go cs
316+ _ -> case cs of
317+ '_':x:xs
318+ | isEnabled Ext_intraword_underscores opts
319+ , isAlphaNum c
320+ , isAlphaNum x -> c : '_' : x : go xs
316− _ -> c : go cs
321+ _ -> c : go cs
317
322
318attrsToMarkdown :: Attr -> Doc Text
323attrsToMarkdown :: Attr -> Doc Text
319attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
324attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
test/command/6296.mdnew file+14
@@ -0,0 +1,14 @@
1+```
2+% pandoc -f native -t markdown
3+[Str "_hi_there"]
4+^D
5+\_hi_there
6+```
7+
8+```
9+% pandoc -f native -t markdown-intraword_underscores
10+[Str "_hi_there"]
11+^D
12+\_hi\_there
13+```
14+
test/writer.markdown+1−1
@@ -683,7 +683,7 @@ Just a [URL](/url/).
683
683
684[URL and title](/url/ "title with single quotes")
684[URL and title](/url/ "title with single quotes")
685
685
686−[with\_underscore](/url/with_underscore)
686+[with_underscore](/url/with_underscore)
687
687
688[Email link](mailto:nobody@nowhere.net)
688[Email link](mailto:nobody@nowhere.net)
689
689