diff --git a/src/core/dfn-index.js b/src/core/dfn-index.js index 3bfa9772e1..068fd161f9 100644 --- a/src/core/dfn-index.js +++ b/src/core/dfn-index.js @@ -100,8 +100,6 @@ const CODE_TYPES = new Set([ export function run() { const index = document.querySelector("section#index"); if (!index) { - // See below... - sub("toc", () => {}, { once: true }); return; } @@ -129,13 +127,12 @@ export function run() { addId(el, "index-term"); } - // XXX: This event is used to overcome an edge case with core/structure, - // related to a circular dependency in plugin run order. We want - // core/structure to run after dfn-index so the #index can be listed in the - // TOC, but we also want section numbers in dfn-index. So, we "split" - // core/dfn-index in two parts, one that runs before core/structure (using - // plugin order in profile) and the other (following) after section numbers - // are generated in core/structure (this event). + // core/dfn-index runs before core/structure (per profile order) so that + // #index appears in the ToC. But section numbers are only assigned by + // core/structure. We resolve this ordering dependency via the "toc" event: + // core/structure emits it after completing section processing and numbering + // (and any ToC generation), at which point we annotate local index entries + // with their section numbers. sub("toc", appendSectionNumbers, { once: true }); sub("beforesave", cleanup);