mirror of
https://github.com/jgm/pandoc.git
synced 2026-10-30 18:24:28 +08:00
Markdown writer: Allow display math to start/end with space.
This reverts to earlier < 3.7 behavior. Closes #11384.
This commit is contained in:
@@ -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 ->
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
```
|
||||
% pandoc -t markdown -f native
|
||||
[ Para [ Math DisplayMath "\ne = mc^2\n" ] ]
|
||||
^D
|
||||
$$
|
||||
e = mc^2
|
||||
$$
|
||||
```
|
||||
|
||||
But we need to collapse spaces around inline math:
|
||||
|
||||
```
|
||||
% pandoc -t markdown -f native
|
||||
[ Para [ Math InlineMath "\ne=mc\n" ]]
|
||||
^D
|
||||
$e=mc$
|
||||
```
|
||||
Reference in New Issue
Block a user