git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: parse page breaks
commit1ca320e249ab72a33e46ca1e73d36b1a818ce008 authorAlexander Krotov <ilabdsf@gmail.com> dateFri 26 Oct 2018, 16:30 (8 years ago) parent74396c7
2 files changed+17−1
src/Text/Pandoc/Readers/Muse.hs+9−1 test/Tests/Readers/Muse.hs+8
src/Text/Pandoc/Readers/Muse.hs+9−1
@@ -32,7 +32,6 @@ Conversion of Muse text to 'Pandoc' document.
3232-}
3333{-
3434TODO:
35−- Page breaks (five "*")
3635- Org tables
3736- table.el tables
3837- <cite> tag
@@ -312,6 +311,7 @@ blockElements :: PandocMonad m => MuseParser m (F Blocks)
312311blockElements = (mempty <$ blankline)
313312 <|> comment
314313 <|> separator
314+ <|> pagebreak
315315 <|> example
316316 <|> exampleTag
317317 <|> literalTag
@@ -342,6 +342,14 @@ separator = try $ pure B.horizontalRule
342342 <* many spaceChar
343343 <* eol
344344
345+-- | Parse a page break
346+pagebreak :: PandocMonad m => MuseParser m (F Blocks)
347+pagebreak = try $ pure (B.divWith ("", [], [("style", "page-break-before: always;")]) mempty)
348+ <$ count 6 spaceChar
349+ <* many spaceChar
350+ <* string "* * * * *"
351+ <* manyTill spaceChar eol
352+
345353headingStart :: PandocMonad m => MuseParser m (String, Int)
346354headingStart = try $ (,)
347355 <$> option "" (try (parseAnchor <* manyTill spaceChar eol))
test/Tests/Readers/Muse.hs+8
@@ -279,6 +279,14 @@ tests =
279279 , "5 dashes is a horizontal rule" =: "-----" =?> horizontalRule
280280 , "4 dashes with spaces is a horizontal rule" =: "---- " =?> horizontalRule
281281 ]
282+ , testGroup "Page breaks"
283+ [ "Page break" =:
284+ " * * * * *" =?>
285+ divWith ("", [], [("style", "page-break-before: always;")]) mempty
286+ , "Page break with trailing space" =:
287+ " * * * * * " =?>
288+ divWith ("", [], [("style", "page-break-before: always;")]) mempty
289+ ]
282290 , testGroup "Paragraphs"
283291 [ "Simple paragraph" =:
284292 T.unlines [ "First line"