Muse reader: parse <div> tag (#3888)

This commit is contained in:
Alexander 2017-09-05 07:22:40 +03:00 committed by John MacFarlane
parent 2637df2bdf
commit c09b586147
2 changed files with 15 additions and 0 deletions

View file

@ -179,6 +179,7 @@ blockElements = choice [ comment
, centerTag
, rightTag
, quoteTag
, divTag
, verseTag
, lineBlock
, bulletList
@ -245,6 +246,12 @@ rightTag = blockTag id "right"
quoteTag :: PandocMonad m => MuseParser m (F Blocks)
quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote"
-- <div> tag is supported by Emacs Muse, but not Amusewiki 2.025
divTag :: PandocMonad m => MuseParser m (F Blocks)
divTag = do
(attrs, content) <- parseHtmlContentWithAttrs "div" block
return $ (B.divWith attrs) <$> mconcat content
verseLine :: PandocMonad m => MuseParser m String
verseLine = do
line <- anyLine <|> many1Till anyChar eof

View file

@ -145,6 +145,14 @@ tests =
, " with a continuation"
] =?>
blockQuote (para "This is a quotation with a continuation")
, testGroup "Div"
[ "Div without id" =:
"<div>Foo bar</div>" =?>
divWith nullAttr (para "Foo bar")
, "Div with id" =:
"<div id=\"foo\">Foo bar</div>" =?>
divWith ("foo", [], []) (para "Foo bar")
]
, "Verse" =:
T.unlines [ "> This is"
, "> First stanza"