From ca7101765ce7c2333b7377d9334be7b6b85fec9a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 6 Jul 2023 09:46:08 -0700 Subject: [PATCH] Typst reader: allow block-level content in text element. --- src/Text/Pandoc/Readers/Typst.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs index bff232722..4d68b431e 100644 --- a/src/Text/Pandoc/Readers/Typst.hs +++ b/src/Text/Pandoc/Readers/Typst.hs @@ -107,6 +107,11 @@ handleBlock tok = do case tok of Txt {} -> fail "pBlockElt encountered Txt" Lab {} -> pure mempty + Elt "text" _ fields -> do + body <- getField "body" fields + -- sometimes text elements include para breaks + notFollowedBy $ void $ pWithContents pInlines body + pWithContents pBlocks body Elt "heading" _ fields -> do body <- getField "body" fields lev <- getField "level" fields <|> pure 1 @@ -331,6 +336,7 @@ isInline (Lab {}) = True isInline (Txt {}) = True isInline (Elt "place" _ _) = True -- can be block or inline isInline (Elt "align" _ _) = True -- can be block or inline +isInline (Elt "text" _ _) = True -- can be block or inline isInline x = not (isBlock x) isBlock :: Content -> Bool @@ -338,6 +344,7 @@ isBlock (Txt {}) = False isBlock (Lab {}) = True isBlock (Elt name _ fields) = case name of + "text" -> True -- can be block or inline "align" -> True "bibliography" -> True "block" -> True