aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2019-10-15 16:36:05 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2019-10-15 16:36:05 +0300
commita1977dd2d67e6ccbafaf7ac25f941bdd399469fa (patch)
treee6fcf7e7b056d78218a0052bef1bd741a574f9ef
parenta0aeb135b39687c1a1c6adb4aa6b01dcc9c6e867 (diff)
downloadpandoc-a1977dd2d67e6ccbafaf7ac25f941bdd399469fa.tar.gz
Muse reader: do not allow closing asterisks to be followed by "*"
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs9
-rw-r--r--test/Tests/Readers/Muse.hs26
2 files changed, 30 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 8a0456981..b8cbe2f26 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -736,6 +736,7 @@ inline' = whitespace
<|> br
<|> anchor
<|> footnote
+ <|> strongEmph
<|> strong
<|> strongTag
<|> emph
@@ -818,13 +819,17 @@ inlineTag tag = try $ mconcat
<$ openTag tag
<*> manyTill inline (closeTag tag)
+-- | Parse strong emphasis inline markup, indicated by @***@.
+strongEmph :: PandocMonad m => MuseParser m (F Inlines)
+strongEmph = fmap (B.strong . B.emph) <$> emphasisBetween (string "***" <* notFollowedBy (char '*'))
+
-- | Parse strong inline markup, indicated by @**@.
strong :: PandocMonad m => MuseParser m (F Inlines)
-strong = fmap B.strong <$> emphasisBetween (string "**")
+strong = fmap B.strong <$> emphasisBetween (string "**" <* notFollowedBy (char '*'))
-- | Parse emphasis inline markup, indicated by @*@.
emph :: PandocMonad m => MuseParser m (F Inlines)
-emph = fmap B.emph <$> emphasisBetween (char '*')
+emph = fmap B.emph <$> emphasisBetween (char '*' <* notFollowedBy (char '*'))
-- | Parse underline inline markup, indicated by @_@.
-- Supported only in Emacs Muse mode, not Text::Amuse.
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 39f7bf903..ab48fd415 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -139,11 +139,31 @@ tests =
, "Asterisk between words does not terminate emphasis" =:
"*foo*bar*" =?>
- para (emph $ "foo*bar")
+ para (emph "foo*bar")
- , "Asterisks between words do not terminate strong" =:
+ , "Two asterisks between words do not terminate emphasis" =:
+ "*foo**bar*" =?>
+ para (emph "foo**bar")
+
+ , "Three asterisks between words do not terminate emphasis" =:
+ "*foo***bar*" =?>
+ para (emph "foo***bar")
+
+ , "Two asterisks between words do not terminate strong" =:
"**foo**bar**" =?>
- para (strong $ "foo**bar")
+ para (strong "foo**bar")
+
+ , "Three asterisks between words do not terminate strong" =:
+ "**foo***bar**" =?>
+ para (strong "foo***bar")
+
+ , "Three asterisks between words do not terminate strong emphasis" =:
+ "***foo***bar***" =?>
+ para (strong . emph $ "foo***bar")
+
+ , "Six asterisks between words do not terminate strong emphasis" =:
+ "***foo******bar***" =?>
+ para (strong . emph $ "foo******bar")
, test emacsMuse "Underline"
("_Underline_" =?> para (underlineSpan "Underline"))