Muse reader: parse <class> tag
<class> tag is supported by Emacs Muse
This commit is contained in:
parent
0bdabfb09a
commit
9bcd090848
2 changed files with 11 additions and 0 deletions
|
@ -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 "~~"
|
||||
|
|
|
@ -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"))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue