git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: add support for <biblio> and <play> tags
commitebbd441d062f71c9a347704730f5ea3247527045 authorAlexander Krotov <ilabdsf@gmail.com> dateSat 7 Apr 2018, 18:31 (9 years ago) parenteecf609
2 files changed+32−2
src/Text/Pandoc/Readers/Muse.hs+15−2 test/Tests/Readers/Muse.hs+17
src/Text/Pandoc/Readers/Muse.hs+15−2
@@ -36,8 +36,7 @@ TODO:
3636- Org tables
3737- table.el tables
3838- Images with attributes (floating and width)
39−- Citations and <biblio>
40−- <play> environment
39+- <cite> tag
4140-}
4241module Text.Pandoc.Readers.Muse (readMuse) where
4342
@@ -322,6 +321,8 @@ blockElements = do
322321 , rightTag
323322 , quoteTag
324323 , divTag
324+ , biblioTag
325+ , playTag
325326 , verseTag
326327 , lineBlock
327328 , table
@@ -413,6 +414,18 @@ divTag = do
413414 (attrs, content) <- parseHtmlContent "div"
414415 return $ B.divWith attrs <$> content
415416
417+-- <biblio> tag is supported by Amusewiki only
418+biblioTag :: PandocMonad m => MuseParser m (F Blocks)
419+biblioTag = do
420+ guardEnabled Ext_amuse
421+ fmap (B.divWith ("", ["biblio"], [])) . snd <$> parseHtmlContent "biblio"
422+
423+-- <play> tag is supported by Amusewiki only
424+playTag :: PandocMonad m => MuseParser m (F Blocks)
425+playTag = do
426+ guardEnabled Ext_amuse
427+ fmap (B.divWith ("", ["play"], [])) . snd <$> parseHtmlContent "play"
428+
416429verseLine :: PandocMonad m => MuseParser m (F Inlines)
417430verseLine = do
418431 indent <- (B.str <$> many1 (char ' ' >> pure '\160')) <|> pure mempty
test/Tests/Readers/Muse.hs+17
@@ -281,6 +281,23 @@ tests =
281281 ] =?>
282282 divWith ("foo", [], []) (para "Foo bar")
283283 ]
284+ , "Biblio" =:
285+ T.unlines [ "<biblio>"
286+ , ""
287+ , "Author, *Title*, description"
288+ , ""
289+ , "Another author, *Another title*, another description"
290+ , ""
291+ , "</biblio>"
292+ ] =?>
293+ divWith ("", ["biblio"], []) (para (text "Author, " <> emph "Title" <> ", description") <>
294+ para (text "Another author, " <> emph "Another title" <> text ", another description"))
295+ , "Play" =:
296+ T.unlines [ "<play>"
297+ , "Foo bar"
298+ , "</play>"
299+ ] =?>
300+ divWith ("", ["play"], []) (para "Foo bar")
284301 , "Verse" =:
285302 T.unlines [ "> This is"
286303 , "> First stanza"