aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Typst.hs10
-rw-r--r--test/command/10965.md47
2 files changed, 56 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
index 775522ff2..90409cbbf 100644
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -342,9 +342,17 @@ blockToTypst block =
Div (ident,_,kvs) blocks -> do
let lab = toLabel FreestandingLabel ident
let (typstAttrs,typstTextAttrs) = pickTypstAttrs kvs
+ -- Handle lang attribute for Div elements
+ let langAttrs = case lookup "lang" kvs of
+ Nothing -> []
+ Just lang -> case parseLang lang of
+ Left _ -> []
+ Right l -> [("lang",
+ tshow (langLanguage l))]
+ let allTypstTextAttrs = typstTextAttrs ++ langAttrs
contents <- blocksToTypst blocks
return $ "#block" <> toTypstPropsListParens typstAttrs <> "["
- $$ toTypstPoundSetText typstTextAttrs <> contents
+ $$ toTypstPoundSetText allTypstTextAttrs <> contents
$$ ("]" <+> lab)
defListItemToTypst :: PandocMonad m => ([Inline], [[Block]]) -> TW m (Doc Text)
diff --git a/test/command/10965.md b/test/command/10965.md
new file mode 100644
index 000000000..565723278
--- /dev/null
+++ b/test/command/10965.md
@@ -0,0 +1,47 @@
+```
+% pandoc -f markdown -t typst
+::: {lang="en"}
+This text should be in English.
+:::
+^D
+#block[
+#set text(lang: "en"); This text should be in English.
+
+]
+```
+
+```
+% pandoc -f markdown -t typst
+::: {lang="fr"}
+Ce texte devrait être en français.
+:::
+^D
+#block[
+#set text(lang: "fr"); Ce texte devrait être en français.
+
+]
+```
+
+```
+% pandoc -f markdown -t typst
+::: {lang="de-DE"}
+Dieser Text sollte auf Deutsch sein.
+:::
+^D
+#block[
+#set text(lang: "de"); Dieser Text sollte auf Deutsch sein.
+
+]
+```
+
+```
+% pandoc -f markdown -t typst
+::: {lang=""}
+This should not have lang set.
+:::
+^D
+#block[
+This should not have lang set.
+
+]
+```