From a1977dd2d67e6ccbafaf7ac25f941bdd399469fa Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 15 Oct 2019 16:36:05 +0300 Subject: Muse reader: do not allow closing asterisks to be followed by "*" --- src/Text/Pandoc/Readers/Muse.hs | 9 +++++++-- test/Tests/Readers/Muse.hs | 26 +++++++++++++++++++++++--- 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")) -- cgit v1.2.3