Markdown writer: avoid unnecessary escapes before intraword _

when `intraword_underscores` extension is enabled.
Closes #6296.
This commit is contained in:
John MacFarlane 2020-04-17 22:42:21 -07:00
parent 0d2b8e3fe1
commit 9a809d4d01
3 changed files with 21 additions and 2 deletions

View file

@ -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]

14
test/command/6296.md Normal file
View file

@ -0,0 +1,14 @@
```
% pandoc -f native -t markdown
[Str "_hi_there"]
^D
\_hi_there
```
```
% pandoc -f native -t markdown-intraword_underscores
[Str "_hi_there"]
^D
\_hi\_there
```

View file

@ -683,7 +683,7 @@ Just a [URL](/url/).
[URL and title](/url/ "title with single quotes")
[with\_underscore](/url/with_underscore)
[with_underscore](/url/with_underscore)
[Email link](mailto:nobody@nowhere.net)