Skip to content

Commit df29187

Browse files
committed
Typst reader: implement "rotate" as pass-through.
Information about the angle is encoded in an attribute of an enclosing span or div. Closes #11531.
1 parent 381b82e commit df29187

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Text/Pandoc/Readers/Typst.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ blockHandlers = M.fromList
422422
_ -> Just . B.text <$> lift (translateTerm References)
423423
let hdr = maybe mempty (B.header 1) mbTitle
424424
pure $ hdr <> B.divWith ("refs", [], []) mempty)
425+
,("rotate", \_ _ fields -> do
426+
body <- getField "body" fields >>= pWithContents pBlocks
427+
let kvs = case M.lookup "angle" fields of
428+
Just (VAngle ang) -> [("angle", T.pack $ show ang)]
429+
_ -> []
430+
pure $ B.divWith ("", ["rotate"], kvs) body)
425431
]
426432

427433
inlineHandlers :: PandocMonad m =>
@@ -568,6 +574,12 @@ inlineHandlers = M.fromList
568574
,("block", \_ mbident fields ->
569575
maybe id (\ident -> B.spanWith (ident, [], [])) mbident
570576
<$> (getField "body" fields >>= pWithContents pInlines))
577+
,("rotate", \_ _ fields -> do
578+
body <- getField "body" fields >>= pWithContents pInlines
579+
let kvs = case M.lookup "angle" fields of
580+
Just (VAngle ang) -> [("angle", T.pack $ show ang)]
581+
_ -> []
582+
pure $ B.spanWith ("", ["rotate"], kvs) body)
571583
]
572584

573585
getInlineBody :: PandocMonad m => M.Map Identifier Val -> P m (Seq Content)

0 commit comments

Comments
 (0)