aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-03-10 07:27:24 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-03-10 07:27:41 +0300
commit9bcd0908482f26e3630a02e3ad3596a2f67fcab9 (patch)
treed2e16433a79f87b6873c8c76c5541a3ac8976da7
parent0bdabfb09abe96781d72b038c2c40f69901bf0b8 (diff)
downloadpandoc-9bcd0908482f26e3630a02e3ad3596a2f67fcab9.tar.gz
Muse reader: parse <class> tag
<class> tag is supported by Emacs Muse
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs8
-rw-r--r--test/Tests/Readers/Muse.hs3
2 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 4c398080c..3e642b386 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -756,6 +756,7 @@ inlineList = [ whitespace
, subscriptTag
, strikeoutTag
, verbatimTag
+ , classTag
, nbsp
, link
, code
@@ -858,6 +859,13 @@ strikeoutTag = inlineTag B.strikeout "del"
verbatimTag :: PandocMonad m => MuseParser m (F Inlines)
verbatimTag = return . B.text . snd <$> htmlElement "verbatim"
+classTag :: PandocMonad m => MuseParser m (F Inlines)
+classTag = do
+ (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "class" [])
+ res <- manyTill inline (void $ htmlTag (~== TagClose "class"))
+ let classes = maybe [] words $ lookup "name" attrs
+ return $ B.spanWith ("", classes, []) <$> mconcat res
+
nbsp :: PandocMonad m => MuseParser m (F Inlines)
nbsp = try $ do
string "~~"
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 9fa79234b..01e8d7b85 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -173,6 +173,9 @@ tests =
, "Verbatim tag after text" =: "Foo <verbatim>bar</verbatim>" =?> para "Foo bar"
+ , "Class tag" =: "<class name=\"foo\">bar</class>" =?> para (spanWith ("", ["foo"], []) "bar")
+ , "Class tag without name" =: "<class>foobar</class>" =?> para (spanWith ("", [], []) "foobar")
+
-- <em> tag should match with the last </em> tag, not verbatim one
, "Nested \"</em>\" inside em tag" =: "<em>foo<verbatim></em></verbatim>bar</em>" =?> para (emph ("foo</em>bar"))