summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-04-05 12:56:51 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-04-05 12:57:25 -0700
commit826b8912ad8c7915432df548f030a095899e6078 (patch)
tree68dceb32a706d960da92a2e5d656cc32ad8e7a28 /src
parent0353e11e27c08d211cea13bbad1ad968845dc29e (diff)
Typst writer: use `<..>` for labels, create internal links.
Internal links to labels are now supported.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Typst.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
index 208d90c7c..b290506a8 100644
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -276,7 +276,10 @@ inlineToTypst inline =
else inlinesToTypst inlines
Link _attrs inlines (src,_tit) -> do
contents <- inlinesToTypst inlines
- return $ "#link" <> parens (doubleQuoted src) <>
+ let dest = case T.uncons src of
+ Just ('#', ident) -> "<" <> literal ident <> ">"
+ _ -> doubleQuoted src
+ return $ "#link" <> parens dest <>
if render Nothing contents == src
then mempty
else nowrap $ brackets contents
@@ -325,7 +328,7 @@ toLabel :: Text -> Doc Text
toLabel ident =
if T.null ident
then mempty
- else "#label" <> parens (doubleQuotes (literal ident))
+ else "<" <> literal ident <> ">"
doubleQuoted :: Text -> Doc Text
doubleQuoted = doubleQuotes . literal . escape