From c93acab035e9f7f3576199ce1bf4009cc4530dcf Mon Sep 17 00:00:00 2001 From: Raymond Berger Date: Wed, 10 Sep 2025 03:56:16 -0400 Subject: [PATCH] Add support for reading typst pagebreak (#11126) The pagebreak is parsed as a HorizontalRule inside a wrapper Div with class `page-break`. Closes #11101. --- src/Text/Pandoc/Readers/Typst.hs | 1 + test/command/11101.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/command/11101.md diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs index cf869bd73..535038c16 100644 --- a/src/Text/Pandoc/Readers/Typst.hs +++ b/src/Text/Pandoc/Readers/Typst.hs @@ -396,6 +396,7 @@ blockHandlers = M.fromList getField "body" fields >>= pWithContents pBlocks) ,("pad", \_ _ fields -> -- ignore paddingy getField "body" fields >>= pWithContents pBlocks) + ,("pagebreak", \_ _ _ -> pure $ B.divWith ("", ["page-break"], [("wrapper", "1")]) B.horizontalRule) ] inlineHandlers :: PandocMonad m => diff --git a/test/command/11101.md b/test/command/11101.md new file mode 100644 index 000000000..77ce03045 --- /dev/null +++ b/test/command/11101.md @@ -0,0 +1,15 @@ +``` +% pandoc -f typst -t native +First paragraph. + +#pagebreak() + +Second paragraph. +^D +[ Para [ Str "First" , Space , Str "paragraph." ] +, Div + ( "" , [ "page-break" ] , [ ( "wrapper" , "1" ) ] ) + [ HorizontalRule ] +, Para [ Str "Second" , Space , Str "paragraph." ] +] +``` \ No newline at end of file