EPUB: appendix chapters never get epub:type="appendix" (book-numbering.lua reads file.appendix instead of the file-metadata state)

Ouverte Adaptée aux débutants
#15,408 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
1/5
Temps estimé
Moins d'une heure
Accessibilité débutants
85/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
lua, typescript
Domaine
documentation

Piste de recherche

Le bogue se trouve dans le gestionnaire Header de src/resources/filters/quarto-pre/book-numbering.lua, vers la ligne 111, qui lit l'indicateur d'annexe dans la mauvaise table. Compare cela avec l'endroit où common/filemetadata.lua définit l'indicateur d'annexe dans la table d'état. Génère un petit livre EPUB avec une annexe, puis vérifie que la section de l'annexe reçoit epub:type="appendix". C'est terminé lorsque cet attribut apparaît dans la sortie et que le reste de la sortie EPUB reste inchangé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

In an EPUB book, appendix chapters never get epub:type="appendix", although src/resources/filters/quarto-pre/book-numbering.lua has a rule meant to add it.

Cause

The rule reads the wrong table. In the Header handler (quarto-pre/book-numbering.lua, line 111 on main at cda410214):

local file = currentFileMetadataState().file
...
-- mark appendix chapters for epub
if el.level == 1 and _quarto.format.isEpubOutput() then
  if file.appendix == true and bookItemType == "chapter" then
    el.attr.attributes["epub:type"] = "appendix"
  end
end

file is the decoded per-item JSON that bookItemMetadata in src/project/types/book/book-render.ts writes (resourceDir, bookItemType, bookItemNumber, bookItemFile, bookItemDepth). It has no appendix field, so file.appendix is always nil and the branch is dead.

The flag the rule wants exists, but on the state table: common/filemetadata.lua sets fileMetadataState.appendix = true when it parses the item whose bookItemType is "appendix" (the appendix divider), and appendix chapters are typed "chapter". So the correct read is currentFileMetadataState().appendix.

Reproduction

_quarto.yml:

project:
  type: book
book:
  title: "Appendix repro"
  author: "x"
  chapters:
    - index.qmd
    - intro.qmd
  appendices:
    - appendix-a.qmd
format:
  epub: default

index.qmd is # Preface {.unnumbered}, intro.qmd is # Intro, and appendix-a.qmd is # Extra material, each with a line of body text. Run quarto render --to epub, unzip the result and search for epub:type="appendix".

  • Observed (dev build with the filters of v1.11.6, and the same code is on main): no match.
  • With only line 111 changed to if currentFileMetadataState().appendix == true and bookItemType == "chapter" then: exactly one match, <section id="extra-material" class="level1" epub:type="appendix">, and no other change to the output.

I searched existing issues for this (queries on epub:type, appendix and epub, bookItemMetadata) and found nothing; #14616 is about the PDF appendix heading, a different problem.

Fix

The one-line change above. It changes EPUB output (appendix chapters gain the semantic attribute), which is the behavior the rule was written for.

Context

Found while working on quarto-dev/quarto-pandoc-resources, a shared home for these filters. The fix will be carried there. If quarto-cli adopts that repository, this issue is fixed by the move; until then it can also be fixed here directly.

Langage dominant
JavaScript
Étoiles
6.2k
Forks
492
Merge moyen
15 h 15 min
PR mergées (30 j)
94

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de quarto-dev/quarto-cli

Toutes les issues de quarto-dev/quarto-cli

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.