diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2021-01-29 18:29:17 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2021-01-29 18:29:17 -0800 | 
| commit | 9223788a05fe619d567bcbdf4cb31db63de86f32 (patch) | |
| tree | a1ab1dc4c43e67c7062dc97e5617c725d2d36338 | |
| parent | d82fe52a02e43d905f34830162def346d851fc5a (diff) | |
| download | pandoc-9223788a05fe619d567bcbdf4cb31db63de86f32.tar.gz | |
Markdown writer: handle math right before digit.
We insert an HTML comment to avoid a `$` right before
a digit, which pandoc will not recognize as a math delimiter.
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 6 | ||||
| -rw-r--r-- | test/command/7058.md | 6 | 
2 files changed, 11 insertions, 1 deletions
| diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index de9075ac4..898905603 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -22,7 +22,7 @@ module Text.Pandoc.Writers.Markdown (    writePlain) where  import Control.Monad.Reader  import Control.Monad.State.Strict -import Data.Char (isAlphaNum) +import Data.Char (isAlphaNum, isDigit)  import Data.Default  import Data.List (find, intersperse, sortOn, transpose)  import qualified Data.Map as M @@ -987,6 +987,10 @@ inlineListToMarkdown opts lst = do    inlist <- asks envInList    go (if inlist then avoidBadWrapsInList lst else lst)    where go [] = return empty +        go (x@Math{}:y@(Str t):zs) +          | T.all isDigit (T.take 1 t) -- starts with digit -- see #7058 +          = liftM2 (<>) (inlineToMarkdown opts x) +              (go (RawInline (Format "html") "<!-- -->" : y : zs))          go (i:is) = case i of              Link {} -> case is of                  -- If a link is followed by another link, or '[', '(' or ':' diff --git a/test/command/7058.md b/test/command/7058.md new file mode 100644 index 000000000..69e5dd445 --- /dev/null +++ b/test/command/7058.md @@ -0,0 +1,6 @@ +``` +% pandoc -f latex -t markdown +5\(-\)8 \(x\) +^D +5$-$`<!-- -->`{=html}8 $x$ +``` | 
