git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: parse <class> tag

<class> tag is supported by Emacs Muse

commit9bcd0908482f26e3630a02e3ad3596a2f67fcab9 authorAlexander Krotov <ilabdsf@gmail.com> dateSat 10 Mar 2018, 07:27 (9 years ago) parent0bdabfb
2 files changed+11
src/Text/Pandoc/Readers/Muse.hs+8 test/Tests/Readers/Muse.hs+3
src/Text/Pandoc/Readers/Muse.hs+8
@@ -756,6 +756,7 @@ inlineList = [ whitespace
756756 , subscriptTag
757757 , strikeoutTag
758758 , verbatimTag
759+ , classTag
759760 , nbsp
760761 , link
761762 , code
@@ -858,6 +859,13 @@ strikeoutTag = inlineTag B.strikeout "del"
858859verbatimTag :: PandocMonad m => MuseParser m (F Inlines)
859860verbatimTag = return . B.text . snd <$> htmlElement "verbatim"
860861
862+classTag :: PandocMonad m => MuseParser m (F Inlines)
863+classTag = do
864+ (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "class" [])
865+ res <- manyTill inline (void $ htmlTag (~== TagClose "class"))
866+ let classes = maybe [] words $ lookup "name" attrs
867+ return $ B.spanWith ("", classes, []) <$> mconcat res
868+
861869nbsp :: PandocMonad m => MuseParser m (F Inlines)
862870nbsp = try $ do
863871 string "~~"
test/Tests/Readers/Muse.hs+3
@@ -173,6 +173,9 @@ tests =
173173
174174 , "Verbatim tag after text" =: "Foo <verbatim>bar</verbatim>" =?> para "Foo bar"
175175
176+ , "Class tag" =: "<class name=\"foo\">bar</class>" =?> para (spanWith ("", ["foo"], []) "bar")
177+ , "Class tag without name" =: "<class>foobar</class>" =?> para (spanWith ("", [], []) "foobar")
178+
176179 -- <em> tag should match with the last </em> tag, not verbatim one
177180 , "Nested \"</em>\" inside em tag" =: "<em>foo<verbatim></em></verbatim>bar</em>" =?> para (emph ("foo</em>bar"))
178181