From 14f813c3f294739f3965058e27eb228ab3ed90d5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 29 Aug 2017 22:40:34 +0300 Subject: Muse reader: parse verse markup (#3882) --- src/Text/Pandoc/Readers/Muse.hs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 2947c50d6..a4512cdd7 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -32,7 +32,6 @@ TODO: - {{{ }}} syntax for - Page breaks (five "*") - Headings with anchors (make it round trip with Muse writer) -- Verse markup (">") - Org tables - table.el tables - Images with attributes (floating and width) @@ -181,6 +180,7 @@ blockElements = choice [ comment , rightTag , quoteTag , verseTag + , lineBlock , bulletList , orderedList , definitionList @@ -298,6 +298,26 @@ noteBlock = try $ do blocksTillNote = many1Till block (eof <|> () <$ lookAhead noteMarker) +-- +-- Verse markup +-- + +lineVerseLine :: PandocMonad m => MuseParser m String +lineVerseLine = try $ do + char '>' + white <- many1 (char ' ' >> pure '\160') + rest <- anyLine + return $ tail white ++ rest + +blanklineVerseLine :: PandocMonad m => MuseParser m Char +blanklineVerseLine = try $ char '>' >> blankline + +lineBlock :: PandocMonad m => MuseParser m (F Blocks) +lineBlock = try $ do + lns <- many1 (pure <$> blanklineVerseLine <|> lineVerseLine) + lns' <- mapM (parseFromString' (trimInlinesF . mconcat <$> many inline)) lns + return $ B.lineBlock <$> sequence lns' + -- -- lists -- -- cgit v1.2.3