Skip to content

Commit

Permalink
Muse reader: add comments support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krotov committed Apr 30, 2017
1 parent 7e8d95d commit 02705ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Text/Pandoc/Readers/Muse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ TODO:
- Tables
- Images with attributes (floating and width)
- Anchors
- Comments
- Citations and <biblio>
- <play> environment
- <verbatim> tag
Expand Down Expand Up @@ -179,16 +178,26 @@ block = do
return res

blockElements :: PandocMonad m => MuseParser m (F Blocks)
blockElements = choice [ separator
blockElements = choice [ comment
, separator
, header
, exampleTag
, literal
, centerTag
, rightTag
, quoteTag
, commentTag
, noteBlock
]

comment :: PandocMonad m => MuseParser m (F Blocks)
comment = try $ do
char ';'
space
many $ noneOf "\n"
(skip newline) <|> eof
return mempty

separator :: PandocMonad m => MuseParser m (F Blocks)
separator = try $ do
string "---"
Expand Down Expand Up @@ -234,6 +243,9 @@ rightTag = blockTag id "right"
quoteTag :: PandocMonad m => MuseParser m (F Blocks)
quoteTag = blockTag B.blockQuote "quote"

commentTag :: PandocMonad m => MuseParser m (F Blocks)
commentTag = parseHtmlContent "comment" block >> return mempty

para :: PandocMonad m => MuseParser m (F Blocks)
para = do
res <- trimInlinesF . mconcat <$> many1Till inline endOfParaElement
Expand Down
6 changes: 6 additions & 0 deletions test/Tests/Readers/Muse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ tests =
[ "Quote" =: "<quote>Hello, world</quote>" =?> blockQuote (para $ text "Hello, world")
, "Center" =: "<center>Hello, world</center>" =?> para (text "Hello, world")
, "Right" =: "<right>Hello, world</right>" =?> para (text "Hello, world")
, testGroup "Comments"
[ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks)
, "Line comment" =: "; Comment" =?> (mempty::Blocks)
, "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment")
, "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment")
]
, testGroup "Headers"
[ "Part" =:
"* First level\n" =?>
Expand Down

0 comments on commit 02705ba

Please sign in to comment.