aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs9
-rw-r--r--test/Tests/Readers/Muse.hs33
2 files changed, 41 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index ab9a51bad..b061d2dfc 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -30,7 +30,6 @@ Conversion of Muse text to 'Pandoc' document.
-}
{-
TODO:
-- {{{ }}} syntax for <example>
- Page breaks (five "*")
- Headings with anchors (make it round trip with Muse writer)
- Org tables
@@ -177,6 +176,7 @@ blockElements :: PandocMonad m => MuseParser m (F Blocks)
blockElements = choice [ comment
, separator
, header
+ , example
, exampleTag
, literal
, centerTag
@@ -221,6 +221,13 @@ header = try $ do
attr <- registerHeader ("", [], []) (runF content defaultParserState)
return $ B.headerWith attr level <$> content
+example :: PandocMonad m => MuseParser m (F Blocks)
+example = try $ do
+ string "{{{"
+ optionMaybe blankline
+ contents <- manyTill anyChar $ try (optionMaybe blankline >> string "}}}")
+ return $ return $ B.codeBlock contents
+
exampleTag :: PandocMonad m => MuseParser m (F Blocks)
exampleTag = do
(attr, contents) <- htmlElement "example"
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 66c6ea7f2..6e3760222 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -232,6 +232,39 @@ tests =
lineBlock [ "Foo bar" ] <>
lineBlock [ "Foo bar" ] <>
lineBlock [ "\160\160\160Foo" ]
+ , testGroup "Example"
+ [ "Braces on separate lines" =:
+ T.unlines [ "{{{"
+ , "Example line"
+ , "}}}"
+ ] =?>
+ codeBlock "Example line"
+ , "Spaces after opening braces" =:
+ T.unlines [ "{{{ "
+ , "Example line"
+ , "}}}"
+ ] =?>
+ codeBlock "Example line"
+ , "One blank line in the beginning" =:
+ T.unlines [ "{{{"
+ , ""
+ , "Example line"
+ , "}}}"
+ ] =?>
+ codeBlock "\nExample line"
+ , "One blank line in the end" =:
+ T.unlines [ "{{{"
+ , "Example line"
+ , ""
+ , "}}}"
+ ] =?>
+ codeBlock "Example line\n"
+ -- Amusewiki requires braces to be on separate line,
+ -- this is an extension.
+ , "One line" =:
+ "{{{Example line}}}" =?>
+ codeBlock "Example line"
+ ]
, testGroup "Example tag"
[ "Tags on separate lines" =:
T.unlines [ "<example>"