Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ All changes included in 1.9:
- ([#13745](https://github.com/quarto-dev/quarto-cli/issues/13745)): Fix relative `font-paths` from extensions or document metadata not resolving correctly for Typst compilation. Relative paths are now resolved against the document directory before being passed to the Typst CLI.
- ([#13775](https://github.com/quarto-dev/quarto-cli/issues/13775)): Fix brand fonts not being applied when using `citeproc: true` with Typst format. Format detection now properly handles Pandoc format variants like `typst-citations`.
- ([#13868](https://github.com/quarto-dev/quarto-cli/issues/13868)): Add image alt text support for PDF/UA accessibility. Alt text from markdown captions and explicit `alt` attributes is now passed to Typst's `image()` function. (Temporary workaround until [jgm/pandoc#11394](https://github.com/jgm/pandoc/pull/11394) is merged.)
- ([#13917](https://github.com/quarto-dev/quarto-cli/issues/13917)): Fix brand logo paths not resolving correctly for Typst documents in project subdirectories. Brand logo paths are now converted to project-absolute paths before merging with document metadata, replacing the fragile `projectOffset()` workaround.
- ([#13249](https://github.com/quarto-dev/quarto-cli/pull/13249)): Update to Pandoc's Typst template following Pandoc 3.8.3 and Typst 0.14.2 support:
- Code syntax highlighting now uses Skylighting by default.
- New template variables `mathfont`, `codefont`, and `linestretch` for font and line spacing customization.
Expand Down
39 changes: 39 additions & 0 deletions src/core/brand/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,45 @@ export function logoAddLeadingSlashes(
};
}

// Return a copy of the brand with logo paths converted from project-relative
// to project-absolute (leading /). Typst resolves these via --root, which
// points to the project directory. Call this before resolveLogo so that
// brand-sourced paths get the / prefix while document-sourced paths are
// left untouched.
export function brandWithAbsoluteLogoPaths(
brand: LightDarkBrand | undefined,
): LightDarkBrand | undefined {
if (!brand) {
return brand;
}
const transformBrand = (b: Brand | undefined): Brand | undefined => {
if (!b) return b;
const oldLogo = b.processedData.logo;
const logo: ProcessedBrandData["logo"] = { images: {} };
for (const size of Zod.BrandNamedLogo.options) {
if (oldLogo[size]) {
logo[size] = {
...oldLogo[size],
path: ensureLeadingSlashIfNotExternal(oldLogo[size]!.path),
};
}
}
for (const [key, value] of Object.entries(oldLogo.images)) {
logo.images[key] = {
...value,
path: ensureLeadingSlashIfNotExternal(value.path),
};
}
const copy = Object.create(b) as Brand;
copy.processedData = { ...b.processedData, logo };
return copy;
};
return {
light: transformBrand(brand.light),
dark: transformBrand(brand.dark),
};
}

// this a typst workaround but might as well write it as a proper function
export function fillLogoPaths(
brand: LightDarkBrand | undefined,
Expand Down
14 changes: 11 additions & 3 deletions src/format/typst/format-typst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ import {
BrandNamedLogo,
LogoLightDarkSpecifier,
} from "../../resources/types/schema-types.ts";
import { fillLogoPaths, resolveLogo } from "../../core/brand/brand.ts";
import {
brandWithAbsoluteLogoPaths,
fillLogoPaths,
resolveLogo,
} from "../../core/brand/brand.ts";
import { LogoLightDarkSpecifierPathOptional } from "../../resources/types/zod/schema-types.ts";

const typstBookExtension: BookExtension = {
Expand Down Expand Up @@ -98,6 +102,10 @@ export function typstFormat(): Format {
}

const brand = format.render.brand;
// For Typst, convert brand logo paths to project-absolute (with /)
// before merging with document logo metadata. Typst resolves / paths
// via --root which points to the project directory.
const typstBrand = brandWithAbsoluteLogoPaths(brand);
const logoSpec = format
.metadata[kLogo] as LogoLightDarkSpecifierPathOptional;
const sizeOrder: BrandNamedLogo[] = [
Expand All @@ -108,8 +116,8 @@ export function typstFormat(): Format {
// temporary: if document logo has object or light/dark objects
// without path, do our own findLogo to add the path
// typst is the exception not needing path but we'll probably deprecate this
const logo = fillLogoPaths(brand, logoSpec, sizeOrder);
format.metadata[kLogo] = resolveLogo(brand, logo, sizeOrder);
const logo = fillLogoPaths(typstBrand, logoSpec, sizeOrder);
format.metadata[kLogo] = resolveLogo(typstBrand, logo, sizeOrder);
// force columns to wrap and move any 'columns' setting to metadata
const columns = format.pandoc[kColumns];
if (columns) {
Expand Down
4 changes: 0 additions & 4 deletions src/resources/filters/quarto-post/typst-brand-yaml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,6 @@ function render_typst_brand_yaml()
imageFilename = imageFilename and imageFilename:gsub('\\_', '_')
else
-- backslashes need to be doubled for Windows
if imageFilename[1] ~= "/" and _quarto.projectOffset() ~= "." then
local offset = _quarto.projectOffset()
imageFilename = pandoc.path.join({offset, imageFilename})
end
imageFilename = string.gsub(imageFilename, '\\', '\\\\')
end
logoOptions.path = pandoc.RawInline('typst', imageFilename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("moon-face\.png", width: 1\.5in, alt: "MOON"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/moon-face\.png", width: 1\.5in, alt: "MOON"\)\)'
-
- 'background.*sun-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in, alt: "SUN"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in, alt: "SUN"\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-logo-alt.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in, alt: "sun face"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in, alt: "sun face"\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-logo-dark.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("moon-face\.png", width: 1\.5in, alt: "moon face"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/moon-face\.png", width: 1\.5in, alt: "moon face"\)\)'
-
- 'background.*sun-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in, alt: "Sun face image"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in, alt: "Sun face image"\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-logo-large.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-logo-light.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in, alt: "sun face"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in, alt: "sun face"\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
---

## Here we go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("moon-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/moon-face\.png", width: 1\.5in\)\)'
-
- 'background.*sun-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-mode-dark.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("moon-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/moon-face\.png", width: 1\.5in\)\)'
-
- 'background.*sun-face\.png'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/brand-mode/brand-mode-light.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("sun-face\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/sun-face\.png", width: 1\.5in\)\)'
-
- 'background.*moon-face\.png'
---
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/choose-logo-resource.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- []
---

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/dark-logo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("quarto.png", width: 1\.5in, alt: "quarto logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/quarto.png", width: 1\.5in, alt: "quarto logo"\)\)'
- []
---

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/dark-mode-no-dark-logo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("quarto.png", width: 1\.5in, alt: "light logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/quarto.png", width: 1\.5in, alt: "light logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "dark logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "dark logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("dark-logo.png", width: 1\.5in, alt: "dark logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/dark-logo.png", width: 1\.5in, alt: "dark logo"\)\)'
- []
---

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/default-logo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("quarto.png", width: 1\.5in, alt: "quarto logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/quarto.png", width: 1\.5in, alt: "quarto logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("_extensions(/|\\\\)my-org(/|\\\\)my-brand(/|\\\\)images(/|\\\\)sun-face.png", width: 1\.5in, alt: "sun face"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/_extensions(/|\\\\)my-org(/|\\\\)my-brand(/|\\\\)images(/|\\\\)sun-face.png", width: 1\.5in, alt: "sun face"\)\)'
-
- 'image\.*moon-face'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("_extensions(/|\\\\)my-brand(/|\\\\)sun-face.png", width: 1\.5in, alt: "sun face"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/_extensions(/|\\\\)my-brand(/|\\\\)sun-face.png", width: 1\.5in, alt: "sun face"\)\)'
-
- 'image.*moon-face'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("quarto-dark.png", width: 1\.5in, alt: "quarto dark logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/quarto-dark.png", width: 1\.5in, alt: "quarto dark logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("custom-dark.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/custom-dark.png", width: 1\.5in\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("dark-large.png", width: 1\.5in, alt: "dark large logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/dark-large.png", width: 1\.5in, alt: "dark large logo"\)\)'
- []
---

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/override-dark-logo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("quarto-dark.png", width: 1\.5in, alt: "quarto dark logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/quarto-dark.png", width: 1\.5in, alt: "quarto dark logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "logo of posit"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "logo of posit"\)\)'
- []
---

Expand Down
2 changes: 1 addition & 1 deletion tests/docs/smoke-all/brand/logo/override-logo-resource.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- '#set page\(background:.*image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)favicon\.png'
- '#set page\(background:.*image\("/brand(/|\\\\)images(/|\\\\)favicon\.png'
- '#box\(image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)logo.png"\)\)'
- '#box\(image\("\.\.(/|\\\\)brand(/|\\\\)images(/|\\\\)header.png"\)\)'
- []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0\.75in, image\("logos(/|\\\\)logo\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0\.75in, image\("/logos(/|\\\\)logo\.png", width: 1\.5in\)\)'
- []
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- 'background: align\(left\+top, box\(inset: 0\.75in, image\("logos(/|\\\\)logo\.png", width: 1\.5in\)\)'
- 'background: align\(left\+top, box\(inset: 0\.75in, image\("/logos(/|\\\\)logo\.png", width: 1\.5in\)\)'
- []
---

Expand Down
Loading
Loading