aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-09-02 00:35:26 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-09-02 01:03:43 +0300
commit23ed97f081d2a5f1ba1d9525e74dfcfbdcfe6a20 (patch)
treee1ab05c2df14bbb42d8adc7dc9681ea44eae24df
parentdb44ddfbde16d8aff0d62550014ac72b684b3eef (diff)
downloadpandoc-23ed97f081d2a5f1ba1d9525e74dfcfbdcfe6a20.tar.gz
Muse reader: allow newline after opening "*" or "**"
Emacs Muse allows this.
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs10
-rw-r--r--test/Tests/Readers/Muse.hs8
2 files changed, 17 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 2b55251e8..045feedb3 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -58,7 +58,7 @@ import Text.Pandoc.Class (PandocMonad (..))
import Text.Pandoc.Definition
import Text.Pandoc.Logging
import Text.Pandoc.Options
-import Text.Pandoc.Parsing hiding (F)
+import Text.Pandoc.Parsing hiding (F, enclosed)
import Text.Pandoc.Readers.HTML (htmlTag)
import Text.Pandoc.Shared (crFilter, underlineSpan)
@@ -839,6 +839,14 @@ br = try $ do
emphasisBetween :: (PandocMonad m, Show a) => MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween c = try $ enclosedInlines c c
+-- | Parses material enclosed between start and end parsers.
+enclosed :: (Show end, Stream s m Char) => ParserT s st m t -- ^ start parser
+ -> ParserT s st m end -- ^ end parser
+ -> ParserT s st m a -- ^ content parser (to be used repeatedly)
+ -> ParserT s st m [a]
+enclosed start end parser = try $
+ start >> notFollowedBy spaceChar >> many1Till parser end
+
enclosedInlines :: (PandocMonad m, Show a, Show b)
=> MuseParser m a
-> MuseParser m b
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 20603b8fb..ca3324e34 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -62,6 +62,14 @@ tests =
"*Foo bar*" =?>
para (emph . spcSep $ ["Foo", "bar"])
+ -- Emacs Muse allows this
+ , "Newline in the beginning of emphasis" =:
+ "*\nFoo bar*" =?>
+ para (emph ("Foo" <> space <> "bar"))
+ , "Newline in the end of emphasis" =:
+ "*Foo bar\n*" =?>
+ para (emph ("Foo" <> space <> "bar"))
+
, "Comma after closing *" =:
"Foo *bar*, baz" =?>
para ("Foo " <> emph "bar" <> ", baz")