aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs11
-rw-r--r--tests/markdown-reader-more.native4
-rw-r--r--tests/markdown-reader-more.txt4
3 files changed, 15 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 80bc53966..d03a1123f 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -45,7 +45,7 @@ import Text.Pandoc.Readers.HTML ( rawHtmlBlock, anyHtmlBlockTag,
htmlBlockElement, unsanitaryURI )
import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
import Text.ParserCombinators.Parsec
-import Control.Monad (when)
+import Control.Monad (when, liftM)
-- | Read markdown from an input string and return a Pandoc document.
readMarkdown :: ParserState -- ^ Parser state, including options for parser
@@ -897,8 +897,13 @@ code = try $ do
return $ Code $ removeLeadingTrailingSpace $ concat result
mathWord :: GenParser Char st [Char]
-mathWord = many1 ((noneOf " \t\n\\$") <|>
- (try (char '\\') >>~ notFollowedBy (char '$')))
+mathWord = liftM concat $ many1 mathChunk
+
+mathChunk :: GenParser Char st [Char]
+mathChunk = do char '\\'
+ c <- anyChar
+ return ['\\',c]
+ <|> many1 (noneOf " \t\n\\$")
math :: GenParser Char ParserState Inline
math = (mathDisplay >>= return . Math DisplayMath)
diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native
index 3160f0cd3..995991a17 100644
--- a/tests/markdown-reader-more.native
+++ b/tests/markdown-reader-more.native
@@ -13,5 +13,7 @@ Pandoc (Meta [] [] "")
, HorizontalRule
, Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]
, Plain [HtmlInline "<a>",HtmlInline "</a>"]
-, Header 3 [Str "my",Space,Str "header"] ]
+, Header 3 [Str "my",Space,Str "header"]
+, Header 2 [Str "$",Space,Str "in",Space,Str "math"]
+, Para [Math InlineMath "\\$2 + \\$3"] ]
diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt
index d2315046f..a7d64dde9 100644
--- a/tests/markdown-reader-more.txt
+++ b/tests/markdown-reader-more.txt
@@ -47,3 +47,7 @@
### my header
+## $ in math
+
+$\$2 + \$3$
+