diff options
| author | John MacFarlane <[email protected]> | 2026-01-08 11:41:35 +0100 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2026-01-08 11:41:35 +0100 |
| commit | 8123be654d6ece208df32afc26b4fe1629e78ffd (patch) | |
| tree | 5537f0f037340241fddbcd76e57b81059086a4ac /src | |
| parent | 6c28eadd6c04a60d0a12efaf864dea1a6b2f2b72 (diff) | |
Markdown writer: Allow display math to start/end with space.
This reverts to earlier < 3.7 behavior.
Closes #11384.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown/Inline.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown/Inline.hs b/src/Text/Pandoc/Writers/Markdown/Inline.hs index b04b320ff..8279d7fcb 100644 --- a/src/Text/Pandoc/Writers/Markdown/Inline.hs +++ b/src/Text/Pandoc/Writers/Markdown/Inline.hs @@ -500,24 +500,24 @@ inlineToMarkdown opts (Str str) = do else escapeText opts) $ str return $ literal str' inlineToMarkdown opts (Math InlineMath str) = do + let str' = T.strip str variant <- asks envVariant case () of _ | variant == Markua -> return $ "`" <> literal str <> "`" <> "$" | otherwise -> case writerHTMLMathMethod opts of WebTeX url -> - let str' = T.strip str - in inlineToMarkdown opts + inlineToMarkdown opts (Image nullAttr [Str str'] (url <> urlEncode str', str')) _ | isEnabled Ext_tex_math_gfm opts -> - return $ "$`" <> literal str <> "`$" + return $ "$`" <> literal str' <> "`$" | isEnabled Ext_tex_math_dollars opts -> - return $ delimited "$" "$" (literal str) + return $ "$" <> literal str' <> "$" | isEnabled Ext_tex_math_single_backslash opts -> - return $ "\\(" <> literal str <> "\\)" + return $ "\\(" <> literal str' <> "\\)" | isEnabled Ext_tex_math_double_backslash opts -> - return $ "\\\\(" <> literal str <> "\\\\)" + return $ "\\\\(" <> literal str' <> "\\\\)" | otherwise -> - texMathToInlines InlineMath str >>= + texMathToInlines InlineMath str' >>= inlineListToMarkdown opts . (if variant == PlainText then makeMathPlainer else id) @@ -540,7 +540,7 @@ inlineToMarkdown opts (Math DisplayMath str) = do $$ literal (T.dropAround (=='\n') str) $$ literal "```") <> cr | isEnabled Ext_tex_math_dollars opts -> - return $ delimited "$$" "$$" (literal str) + return $ "$$" <> literal str <> "$$" | isEnabled Ext_tex_math_single_backslash opts -> return $ "\\[" <> literal str <> "\\]" | isEnabled Ext_tex_math_double_backslash opts -> |
