Muse reader: add support for <biblio> and <play> tags

This commit is contained in:
Alexander Krotov 2018-04-07 18:31:06 +03:00
parent eecf609792
commit ebbd441d06
2 changed files with 32 additions and 2 deletions

View file

@ -36,8 +36,7 @@ TODO:
- Org tables - Org tables
- table.el tables - table.el tables
- Images with attributes (floating and width) - Images with attributes (floating and width)
- Citations and <biblio> - <cite> tag
- <play> environment
-} -}
module Text.Pandoc.Readers.Muse (readMuse) where module Text.Pandoc.Readers.Muse (readMuse) where
@ -322,6 +321,8 @@ blockElements = do
, rightTag , rightTag
, quoteTag , quoteTag
, divTag , divTag
, biblioTag
, playTag
, verseTag , verseTag
, lineBlock , lineBlock
, table , table
@ -413,6 +414,18 @@ divTag = do
(attrs, content) <- parseHtmlContent "div" (attrs, content) <- parseHtmlContent "div"
return $ B.divWith attrs <$> content return $ B.divWith attrs <$> content
-- <biblio> tag is supported by Amusewiki only
biblioTag :: PandocMonad m => MuseParser m (F Blocks)
biblioTag = do
guardEnabled Ext_amuse
fmap (B.divWith ("", ["biblio"], [])) . snd <$> parseHtmlContent "biblio"
-- <play> tag is supported by Amusewiki only
playTag :: PandocMonad m => MuseParser m (F Blocks)
playTag = do
guardEnabled Ext_amuse
fmap (B.divWith ("", ["play"], [])) . snd <$> parseHtmlContent "play"
verseLine :: PandocMonad m => MuseParser m (F Inlines) verseLine :: PandocMonad m => MuseParser m (F Inlines)
verseLine = do verseLine = do
indent <- (B.str <$> many1 (char ' ' >> pure '\160')) <|> pure mempty indent <- (B.str <$> many1 (char ' ' >> pure '\160')) <|> pure mempty

View file

@ -281,6 +281,23 @@ tests =
] =?> ] =?>
divWith ("foo", [], []) (para "Foo bar") divWith ("foo", [], []) (para "Foo bar")
] ]
, "Biblio" =:
T.unlines [ "<biblio>"
, ""
, "Author, *Title*, description"
, ""
, "Another author, *Another title*, another description"
, ""
, "</biblio>"
] =?>
divWith ("", ["biblio"], []) (para (text "Author, " <> emph "Title" <> ", description") <>
para (text "Another author, " <> emph "Another title" <> text ", another description"))
, "Play" =:
T.unlines [ "<play>"
, "Foo bar"
, "</play>"
] =?>
divWith ("", ["play"], []) (para "Foo bar")
, "Verse" =: , "Verse" =:
T.unlines [ "> This is" T.unlines [ "> This is"
, "> First stanza" , "> First stanza"