Heading anchor links have no icon: AnchorJS is initialised with an empty `icon`

Abierto Apto para principiantes
#1,419 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cscheid ya está trabajando en esto.

Desde el 30/11/2026.

  • #1422 de @cscheid — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
frontend

Línea de trabajo

Empieza con INIT_SCRIPT en crates/quarto-core/src/transforms/anchor_sections.rs y compara su configuración de AnchorJS con el comportamiento de Quarto 1 descrito en el issue. La salida reportada muestra que el icono generado está vacío; verifica la corrección renderizando la reproducción del sitio web proporcionada y comprobando que el enlace del encabezado muestre el icono de AnchorJS.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

This issue was drafted with Claude. The output shown comes from running each repro.

Bug description

Heading anchor links have no icon. q2 adds the .anchorjs-link to each heading, and the link
appears on hover, but it is empty, so readers cannot see or click it.

q2 initialises AnchorJS with icon: ''. Quarto 1 passes a one-character string, U+E9CB, a
private-use glyph that AnchorJS draws with its own anchorjs-icons font. When icon is that
glyph, AnchorJS also sets font: 1em/1 anchorjs-icons on the link. With an empty string it
draws content: attr(data-anchorjs-icon), which is empty.

The cause looks like an invisible character that was lost when the init was ported. In Quarto
1's quarto-html-after-body.ejs (line 75), the line reads
const icon = "<%= anchors === true ? '' : anchors %>";, but the quotes hold U+E9CB:

$ sed -n 75p share/formats/html/templates/quarto-html-after-body.ejs | xxd | sed -n 3p
00000020: 3d20 7472 7565 203f 2027 eea7 8b27 203a  = true ? '...' :

In q2, INIT_SCRIPT in crates/quarto-core/src/transforms/anchor_sections.rs (at 9bf91d18c)
has a truly empty string, and its doc comment says "with icon empty, which is what Q1 renders
for anchors === true":

$ sed -n 126p crates/quarto-core/src/transforms/anchor_sections.rs | xxd
00000000: 2020 2020 6963 6f6e 3a20 2727 5c6e 5c0a      icon: ''\n\.
Steps to reproduce
mkdir anchor-icon && cd anchor-icon
printf 'project:\n  type: website\nwebsite:\n  title: Demo\n' > _quarto.yml
printf -- '---\ntitle: Anchors\n---\n\n## A heading\n\nText.\n' > index.qmd
q2 render
grep -o "icon: [^,}]*" _site/index.html | xxd

Then open _site/index.html and hover over "A heading". There is a link target after the heading
text, but nothing is drawn.

Actual behavior

With q2 0.47.0 and with 0.45.0-nightly.20261112:

00000000: 6963 6f6e 3a20 2727 0a                   icon: ''.
Expected behavior

Quarto 1.11.9 with the same files (quarto render, then
grep -o 'const icon = "[^"]*"' _site/index.html | xxd):

00000000: 636f 6e73 7420 6963 6f6e 203d 2022 eea7  const icon = "..
00000010: 8b22 0a                                  .".

Hovering over the heading shows AnchorJS's link icon.

A possible fix is to write the glyph as an escape in INIT_SCRIPT (icon: '', which is
'\\ue9cb' inside the Rust string), so it cannot be lost again.

Workaround
.anchorjs-link[data-anchorjs-icon=""]::after {
  content: "\e9cb";
  font: 1em/1 anchorjs-icons;
}

AnchorJS registers the anchorjs-icons font whenever it adds links, so this draws the same icon
as Quarto 1, and it stops applying once the icon is set.

Environment
  • q2 0.47.0 (latest release) and 0.45.0-nightly.20261112, macOS arm64
  • Quarto 1.11.9 for the comparison
Lenguaje dominante
Rust
Estrellas
316
Forks
23
Merge medio
11 h 49 min
PR fusionados (30 d)
245

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quarto-dev/q2

Todos los issues de quarto-dev/q2

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.