Skip to content
Open
Changes from 1 commit
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
14 changes: 5 additions & 9 deletions src/core/dfn-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -129,13 +127,11 @@ 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 building the ToC, at which point we can
// annotate each index entry with its section number.
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
sub("toc", appendSectionNumbers, { once: true });

sub("beforesave", cleanup);
Expand Down
Loading