aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2019-10-15 01:55:32 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2019-10-15 01:55:32 +0300
commitd5c13dd4383e4809c4a6e935398a4bfa6e1b04e5 (patch)
tree80f33803ce2191705d06a7e2cbddb6b84e053d18
parent13e0ac1104cc77f15e85fea83f54b6d6ae65271d (diff)
downloadpandoc-d5c13dd4383e4809c4a6e935398a4bfa6e1b04e5.tar.gz
Muse reader: do not split series of asterisks into symbols and emphasis
Fixes #5821
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs7
-rw-r--r--test/Tests/Readers/Muse.hs8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 104fa914f..8a0456981 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -755,6 +755,7 @@ inline' = whitespace
<|> mathTag
<|> inlineLiteralTag
<|> str
+ <|> asterisks
<|> symbol
<?> "inline"
@@ -909,6 +910,12 @@ inlineLiteralTag = try $ fmap pure $ B.rawInline
str :: PandocMonad m => MuseParser m (F Inlines)
str = return . B.str <$> many1 alphaNum <* updateLastStrPos
+-- | Consume asterisks that were not used as emphasis opening.
+-- This prevents series of asterisks from being split into
+-- literal asterisk and emphasis opening.
+asterisks :: PandocMonad m => MuseParser m (F Inlines)
+asterisks = pure . B.str <$> many1 (char '*')
+
symbol :: PandocMonad m => MuseParser m (F Inlines)
symbol = pure . B.str . pure <$> nonspaceChar
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 6a9919233..39f7bf903 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -133,10 +133,18 @@ tests =
"**foo *bar* baz**" =?>
para (strong (text "foo " <> emph (text "bar") <> text " baz"))
+ , "Opening asterisk can't be preceded by another one" =:
+ "**foo*" =?>
+ para "**foo*"
+
, "Asterisk between words does not terminate emphasis" =:
"*foo*bar*" =?>
para (emph $ "foo*bar")
+ , "Asterisks between words do not terminate strong" =:
+ "**foo**bar**" =?>
+ para (strong $ "foo**bar")
+
, test emacsMuse "Underline"
("_Underline_" =?> para (underlineSpan "Underline"))