Skip to content

Commit ea993d4

Browse files
typst brand yaml: resolve logo paths via project directory
1 parent 605263d commit ea993d4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

news/changelog-1.8.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All changes included in 1.8:
2222
- ([#5879](https://github.com/quarto-dev/quarto-cli/issues/5879)): Improve font rendering of `kbd` shortcode on macOS. `kbd` will now also be stricter in converting keyboard shortcuts to macOS icons.
2323
- ([#8568](https://github.com/quarto-dev/quarto-cli/issues/8568)) Default inline code background color to the code block background color if not specified; foreground color is `$pre-color` in dark mode and (remains) purple in light mode.
2424
- ([#10983](https://github.com/quarto-dev/quarto-cli/issues/10983)): Fix spacing inconsistency between paras and first section headings.
25+
- ([#11982](https://github.com/quarto-dev/quarto-cli/issues/11982)): Ensure brand.yml logos are resolved correctly when document is in a subdirectory.
2526
- ([#12259](https://github.com/quarto-dev/quarto-cli/issues/12259)): Fix conflict between `html-math-method: katex` and crossref popups (author: @benkeks).
2627
- ([#12341](https://github.com/quarto-dev/quarto-cli/issues/12341)): Enable light and dark logos for html formats (sidebar, navbar, dashboard).
2728
- ([#12501](https://github.com/quarto-dev/quarto-cli/issues/12501)): Enable `source: file` for `brand.yml` fonts in HTML.
@@ -55,6 +56,7 @@ All changes included in 1.8:
5556
- ([#12815](https://github.com/quarto-dev/quarto-cli/issues/12815)): Do not crash when floats have no content.
5657
- ([#13119](https://github.com/quarto-dev/quarto-cli/pull/13119)): Expose `brand.logo` metadata as Typst dictionaries.
5758
- ([#13133](https://github.com/quarto-dev/quarto-cli/pull/13133)): Allow customization of light and dark logos at document level, consistent with other formats.
59+
- ([#13297](https://github.com/quarto-dev/quarto-cli/pull/13297)): Ensure brand.yml logos are resolved correctly when Typst document is in a subdirectory.
5860

5961
### `beamer`
6062

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ function render_typst_brand_yaml()
318318
imageFilename = imageFilename and imageFilename:gsub('\\_', '_')
319319
else
320320
-- backslashes need to be doubled for Windows
321+
if imageFilename[1] ~= "/" and _quarto.projectOffset() ~= "." then
322+
local offset = _quarto.projectOffset()
323+
imageFilename = pandoc.path.join({offset, imageFilename})
324+
end
321325
imageFilename = string.gsub(imageFilename, '\\', '\\\\')
322326
end
323327
logoOptions.path = pandoc.RawInline('typst', imageFilename)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "tmpsite"
3+
format:
4+
typst:
5+
output-ext: typ
6+
_quarto:
7+
tests:
8+
typst:
9+
ensureTypstFileRegexMatches:
10+
-
11+
- '#set page\(background:.*image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)favicon\.png'
12+
- '#box\(image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)logo.png"\)\)'
13+
- '#box\(image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)header.png"\)\)'
14+
- []
15+
---
16+
17+
18+
{{< brand logo full >}}
19+
20+
Here's some text and [a link](https://example.com).
21+
22+
{{< brand logo header >}}

0 commit comments

Comments
 (0)