@@ -372,17 +372,17 @@ inlineToMarkdown opts (Emph lst) = do
372
372
contents <- inlineListToMarkdown opts lst
373
373
return $ case variant of
374
374
PlainText
375
- | isEnabled Ext_gutenberg opts -> " _" <> contents <> " _"
375
+ | isEnabled Ext_gutenberg opts -> surroundInlines " _" " _" contents
376
376
| otherwise -> contents
377
- _ -> " *" <> contents <> " *"
377
+ _ -> surroundInlines " *" " *" contents
378
378
inlineToMarkdown _ (Underline [] ) = return empty
379
379
inlineToMarkdown opts (Underline lst) = do
380
380
variant <- asks envVariant
381
381
contents <- inlineListToMarkdown opts lst
382
382
case variant of
383
383
PlainText -> return contents
384
384
_ | isEnabled Ext_bracketed_spans opts ->
385
- return $ " [" <> contents <> " ] " <> " {.underline}"
385
+ return $ surroundInlines " [" " ] {.underline}" contents
386
386
| isEnabled Ext_native_spans opts ->
387
387
return $ tagWithAttrs " span" (" " , [" underline" ], [] )
388
388
<> contents
@@ -401,12 +401,12 @@ inlineToMarkdown opts (Strong lst) = do
401
401
else lst
402
402
_ -> do
403
403
contents <- inlineListToMarkdown opts lst
404
- return $ " **" <> contents <> " **"
404
+ return $ surroundInlines " **" " **" contents
405
405
inlineToMarkdown _ (Strikeout [] ) = return empty
406
406
inlineToMarkdown opts (Strikeout lst) = do
407
407
contents <- inlineListToMarkdown opts lst
408
408
return $ if isEnabled Ext_strikeout opts
409
- then " ~~" <> contents <> " ~~"
409
+ then surroundInlines " ~~" " ~~" contents
410
410
else if isEnabled Ext_raw_html opts
411
411
then " <s>" <> contents <> " </s>"
412
412
else contents
@@ -415,7 +415,7 @@ inlineToMarkdown opts (Superscript lst) =
415
415
local (\ env -> env {envEscapeSpaces = envVariant env == Markdown }) $ do
416
416
contents <- inlineListToMarkdown opts lst
417
417
if isEnabled Ext_superscript opts
418
- then return $ " ^" <> contents <> " ^"
418
+ then return $ surroundInlines " ^" " ^" contents
419
419
else if isEnabled Ext_raw_html opts
420
420
then return $ " <sup>" <> contents <> " </sup>"
421
421
else
@@ -433,7 +433,7 @@ inlineToMarkdown opts (Subscript lst) =
433
433
local (\ env -> env {envEscapeSpaces = envVariant env == Markdown }) $ do
434
434
contents <- inlineListToMarkdown opts lst
435
435
if isEnabled Ext_subscript opts
436
- then return $ " ~" <> contents <> " ~"
436
+ then return $ surroundInlines " ~" " ~" contents
437
437
else if isEnabled Ext_raw_html opts
438
438
then return $ " <sub>" <> contents <> " </sub>"
439
439
else
@@ -511,7 +511,7 @@ inlineToMarkdown opts (Math InlineMath str) = do
511
511
_ | isEnabled Ext_tex_math_gfm opts ->
512
512
return $ " $`" <> literal str <> " `$"
513
513
| isEnabled Ext_tex_math_dollars opts ->
514
- return $ " $" <> literal str <> " $ "
514
+ return $ surroundInlines " $" " $ " ( literal str)
515
515
| isEnabled Ext_tex_math_single_backslash opts ->
516
516
return $ " \\ (" <> literal str <> " \\ )"
517
517
| isEnabled Ext_tex_math_double_backslash opts ->
@@ -540,7 +540,7 @@ inlineToMarkdown opts (Math DisplayMath str) = do
540
540
$$ literal str
541
541
$$ literal " ```" ) <> cr
542
542
| isEnabled Ext_tex_math_dollars opts ->
543
- return $ " $$" <> literal str <> " $$"
543
+ return $ surroundInlines " $$" " $$" (literal str)
544
544
| isEnabled Ext_tex_math_single_backslash opts ->
545
545
return $ " \\ [" <> literal str <> " \\ ]"
546
546
| isEnabled Ext_tex_math_double_backslash opts ->
0 commit comments