Muse reader: parse page breaks

This commit is contained in:
Alexander Krotov 2018-10-26 16:30:15 +03:00
parent 74396c7f90
commit 1ca320e249
2 changed files with 17 additions and 1 deletions

View file

@ -32,7 +32,6 @@ Conversion of Muse text to 'Pandoc' document.
-}
{-
TODO:
- Page breaks (five "*")
- Org tables
- table.el tables
- <cite> tag
@ -312,6 +311,7 @@ blockElements :: PandocMonad m => MuseParser m (F Blocks)
blockElements = (mempty <$ blankline)
<|> comment
<|> separator
<|> pagebreak
<|> example
<|> exampleTag
<|> literalTag
@ -342,6 +342,14 @@ separator = try $ pure B.horizontalRule
<* many spaceChar
<* eol
-- | Parse a page break
pagebreak :: PandocMonad m => MuseParser m (F Blocks)
pagebreak = try $ pure (B.divWith ("", [], [("style", "page-break-before: always;")]) mempty)
<$ count 6 spaceChar
<* many spaceChar
<* string "* * * * *"
<* manyTill spaceChar eol
headingStart :: PandocMonad m => MuseParser m (String, Int)
headingStart = try $ (,)
<$> option "" (try (parseAnchor <* manyTill spaceChar eol))

View file

@ -279,6 +279,14 @@ tests =
, "5 dashes is a horizontal rule" =: "-----" =?> horizontalRule
, "4 dashes with spaces is a horizontal rule" =: "---- " =?> horizontalRule
]
, testGroup "Page breaks"
[ "Page break" =:
" * * * * *" =?>
divWith ("", [], [("style", "page-break-before: always;")]) mempty
, "Page break with trailing space" =:
" * * * * * " =?>
divWith ("", [], [("style", "page-break-before: always;")]) mempty
]
, testGroup "Paragraphs"
[ "Simple paragraph" =:
T.unlines [ "First line"