Skip to content

Commit 5e37696

Browse files
use typst raw inline in metadata
to avoid evil eval in typst
1 parent 1959747 commit 5e37696

File tree

7 files changed

+8
-13
lines changed

7 files changed

+8
-13
lines changed

src/resources/filters/quarto-post/typst-brand-yaml.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,14 @@ function render_typst_brand_yaml()
310310
if headings and next(headings) or foregroundColor then
311311
base = base or {}
312312
headings = headings or {}
313+
local color = headings.color or foregroundColor
314+
color = color and pandoc.RawInline('typst', color)
313315
meta.brand.typography.headings = {
314316
family = headings.family or base.family,
315317
weight = headings.weight or base.weight,
316318
style = headings.style or base.style,
317319
decoration = headings.decoration or base.decoration,
318-
color = headings.color or foregroundColor,
320+
color = color,
319321
['background-color'] = headings['background-color'] or base['background-color'],
320322
['line-height'] = line_height_to_leading(headings['line-height'] or base['line-height']),
321323
}

src/resources/formats/typst/pandoc/quarto/definitions.typ

-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242
return block.with(..fields)(new_content)
4343
}
4444

45-
#let unescape-eval(str) = {
46-
return eval(str.replace("\\", ""))
47-
}
48-
4945
#let empty(v) = {
5046
if type(v) == "string" {
5147
// two dollar signs here because we're technically inside

src/resources/formats/typst/pandoc/quarto/typst-show.typ

+1-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ $if(brand.typography.headings.decoration)$
5959
heading-decoration: "$brand.typography.headings.decoration$",
6060
$endif$
6161
$if(brand.typography.headings.color)$
62-
heading-color: unescape-eval("$brand.typography.headings.color$"),
63-
$endif$
64-
$if(brand.typography.headings.background-color)$
65-
heading-background-color: unescape-eval("$brand.typography.headings.background-color$"),
62+
heading-color: $brand.typography.headings.color$,
6663
$endif$
6764
$if(brand.typography.headings.line-height)$
6865
heading-line-height: $brand.typography.headings.line-height$,

tests/docs/smoke-all/typst/brand-yaml/color/foreground-background.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ _quarto:
1818
-
1919
- '#set page\(fill: brand-color\.background\)'
2020
- '#set text\(fill: brand-color\.foreground\)'
21-
- 'heading-color: unescape-eval\("rgb\(\\"\\#ccd2b2\\"\)"\)'
21+
- 'heading-color: rgb\("#ccd2b2"\)'
2222
- []
2323
---
2424

tests/docs/smoke-all/typst/brand-yaml/color/foreground-lines.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _quarto:
1515
-
1616
- '#set page\(fill: brand-color\.background\)'
1717
- '#set text\(fill: brand-color\.foreground\)'
18-
- 'heading-color: unescape-eval\("rgb\(\\"\\#ccd2b2\\"\)"\)'
18+
- 'heading-color: rgb\("#ccd2b2"\)'
1919
- '#set table.hline\(stroke: \(paint: brand-color\.foreground\)\)'
2020
- '#set line\(stroke: \(paint: brand-color\.foreground\)\)'
2121

tests/docs/smoke-all/typst/brand-yaml/typography/kitchen-sink-1/brand-typography.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _quarto:
3030
- 'heading-family: \("Montserrat",\),$'
3131
- 'heading-weight: 800,$'
3232
- 'heading-style: "normal",$'
33-
- 'heading-color: unescape-eval\("rgb\(\\"\\#0b8005\\"\)"\),$'
33+
- 'heading-color: rgb\("#0b8005"\),$'
3434
- 'heading-line-height: 0\.25em,$'
3535
- '^#show heading: set text\(font: "Montserrat", weight: 800, style: "normal", fill: rgb\("#0b8005"\), \)$'
3636
- '^#show heading: set par\(leading: 0.25em\)$'

tests/docs/smoke-all/typst/brand-yaml/typography/kitchen-sink-2/brand-typography.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _quarto:
2828
- 'heading-family: \("Raleway",\),$'
2929
- 'heading-weight: 500,$'
3030
- 'heading-style: "normal",$'
31-
- 'heading-color: unescape-eval\("rgb\(\\"\\#042f02\\"\)"\),$'
31+
- 'heading-color: rgb\("#042f02"\),$'
3232
- 'heading-line-height: 0\.25em,$'
3333
- '^#show heading: set text\(font: "Raleway", weight: 500, style: "normal", fill: rgb\("#042f02"\), \)$'
3434
- '^#show heading: set par\(leading: 0.25em\)$'

0 commit comments

Comments
 (0)