Typst: logo from _brand.yml is drawn on every page and logo: false does not remove it

Aperta Adatta ai principianti
#15,311 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript, yaml
Ambito
backend

Direzione di ricerca

Inizia in src/core/brand/brand.ts da fillLogoPaths() e segui il percorso del suo risultato fino a resolveLogo() da src/format/typst/format-typst.ts. Controlla la gestione esistente di logo: false e lo sfondo della pagina Typst in src/resources/formats/typst/pandoc/quarto/page.typ. Il lavoro è completato quando il rendering con un logo del brand omette il logo con logo: false, mantenendo i colori e i caratteri del brand.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

brand bug typst
Bug description

When _brand.yml defines a logo, Typst output puts it in the page background of every page, and logo: false does not remove it, neither as a typst format option nor at the top level of the front matter.
revealjs honors logo: false with the same _brand.yml, and websites and books document it for navbar and sidebar (https://prerelease.quarto.org/docs/authoring/brand.html#disabling-the-logo).
For Typst, the only document-level switch I found is brand: false, which also drops the brand colors and fonts.

Steps to reproduce

_brand.yml

logo:
  images:
    mark:
      path: logo.svg
      alt: Logo
  small: mark

logo.svg

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="#d33"/></svg>

doc.qmd

---
title: Logo test
format:
  typst:
    logo: false
---

First page paragraph.

{{< pagebreak >}}

Second page paragraph.
quarto render doc.qmd -M keep-typ:true
grep "set page(background" doc.typ

Same result with logo: false at the top level instead of under typst, and without logo at all.

Actual behavior

doc.typ always contains

#set page(background: align(left+top, box(inset: 0.75in, image("/logo.svg", width: 1.5in, alt: "Logo"))))

and the red square is drawn on both pages of the PDF.

Expected behavior

logo: false removes the logo in Typst output, while the rest of _brand.yml still applies.

Cause

The Typst format passes the document logo through fillLogoPaths() before resolveLogo():

https://github.com/quarto-dev/quarto-cli/blob/d5e0617310ce240263f539c16bdd804dd952ed7d/src/format/typst/format-typst.ts#L122-L123

resolveLogo() handles false since #13922 (for navbar and sidebar):

https://github.com/quarto-dev/quarto-cli/blob/d5e0617310ce240263f539c16bdd804dd952ed7d/src/core/brand/brand.ts#L360-L373

but fillLogoPaths() turns any falsy value into undefined first:

https://github.com/quarto-dev/quarto-cli/blob/d5e0617310ce240263f539c16bdd804dd952ed7d/src/core/brand/brand.ts#L593-L595

So resolveLogo() receives undefined and falls back to the first brand logo of small, medium, large, which the page.typ partial then sets as page background:

https://github.com/quarto-dev/quarto-cli/blob/d5e0617310ce240263f539c16bdd804dd952ed7d/src/resources/formats/typst/pandoc/quarto/page.typ#L13-L14

We could let false pass through fillLogoPaths() unchanged so the existing check in resolveLogo() applies.

Workaround

A Typst file in include-in-header that wraps article() and resets the background before any content:

#let quarto-article = article
#let article(..args) = {
  set page(background: none)
  quarto-article(..args)
}
format:
  typst:
    include-in-header: no-logo.typ

It resets any other page background too. A plain #set page(background: none) in include-before-body comes after the title block and adds an extra page.

Your environment
  • Quarto 1.12.0 (prerelease), also 1.11.9
  • Windows 11
Lingua principale
JavaScript
Stelle
6.1k
Fork
478
Merge medio
17h 58m
PR unite (30g)
135

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quarto-dev/quarto-cli

Tutte le issue di quarto-dev/quarto-cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.