From df29187f9ea338fbc57d06c07bb99ba04f735149 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 10 Apr 2026 11:20:46 +0200 Subject: [PATCH] Typst reader: implement "rotate" as pass-through. Information about the angle is encoded in an attribute of an enclosing span or div. Closes #11531. --- src/Text/Pandoc/Readers/Typst.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs index 5fffab208..93cde4f8d 100644 --- a/src/Text/Pandoc/Readers/Typst.hs +++ b/src/Text/Pandoc/Readers/Typst.hs @@ -422,6 +422,12 @@ blockHandlers = M.fromList _ -> Just . B.text <$> lift (translateTerm References) let hdr = maybe mempty (B.header 1) mbTitle pure $ hdr <> B.divWith ("refs", [], []) mempty) + ,("rotate", \_ _ fields -> do + body <- getField "body" fields >>= pWithContents pBlocks + let kvs = case M.lookup "angle" fields of + Just (VAngle ang) -> [("angle", T.pack $ show ang)] + _ -> [] + pure $ B.divWith ("", ["rotate"], kvs) body) ] inlineHandlers :: PandocMonad m => @@ -568,6 +574,12 @@ inlineHandlers = M.fromList ,("block", \_ mbident fields -> maybe id (\ident -> B.spanWith (ident, [], [])) mbident <$> (getField "body" fields >>= pWithContents pInlines)) + ,("rotate", \_ _ fields -> do + body <- getField "body" fields >>= pWithContents pInlines + let kvs = case M.lookup "angle" fields of + Just (VAngle ang) -> [("angle", T.pack $ show ang)] + _ -> [] + pure $ B.spanWith ("", ["rotate"], kvs) body) ] getInlineBody :: PandocMonad m => M.Map Identifier Val -> P m (Seq Content)