Skip to content
Open
Changes from all commits
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
15 changes: 6 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,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);
Expand Down
Loading