aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2021-10-03 18:34:20 -0700
committerJohn MacFarlane <[email protected]>2021-10-03 18:34:20 -0700
commit059eaaea51a08b2b62dfa44d38d29441ad2feb5f (patch)
tree982718f2fa850a6f249e0088530f11e6faca8a6b
parent58839625e33199f11e6e437c52c94eee2c8c9930 (diff)
Markdown writer: escape spaces in Str when needed.
-rw-r--r--src/Text/Pandoc/Writers/Markdown/Inline.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown/Inline.hs b/src/Text/Pandoc/Writers/Markdown/Inline.hs
index b805cb1ce..36ef1804f 100644
--- a/src/Text/Pandoc/Writers/Markdown/Inline.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Inline.hs
@@ -414,7 +414,11 @@ inlineToMarkdown opts (Code attr str) = do
(marker <> spacer <> str <> spacer <> marker) <> attrs
inlineToMarkdown opts (Str str) = do
variant <- asks envVariant
- let str' = (if writerPreferAscii opts
+ escapeSpaces <- asks envEscapeSpaces
+ let str' = (if escapeSpaces
+ then T.replace " " "\\ "
+ else id) .
+ (if writerPreferAscii opts
then toHtml5Entities
else id) .
(if isEnabled Ext_smart opts
@@ -488,10 +492,6 @@ inlineToMarkdown opts LineBreak = do
if isEnabled Ext_escaped_line_breaks opts
then "\\" <> cr
else " " <> cr
--- TODO escape spaces in Str...
--- inlineToMarkdown _ Space = do
--- escapeSpaces <- asks envEscapeSpaces
--- return $ if escapeSpaces then "\\ " else space
inlineToMarkdown opts SoftBreak = do
escapeSpaces <- asks envEscapeSpaces
let space' = if escapeSpaces then "\\ " else space