From 059eaaea51a08b2b62dfa44d38d29441ad2feb5f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 3 Oct 2021 18:34:20 -0700 Subject: Markdown writer: escape spaces in Str when needed. --- src/Text/Pandoc/Writers/Markdown/Inline.hs | 10 +++++----- 1 file 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 -- cgit v1.2.3