Skip to content

Commit

Permalink
fix: remove 1st level embedded heading
Browse files Browse the repository at this point in the history
  • Loading branch information
fnumatic committed Nov 15, 2022
1 parent ca1aec9 commit 8638bc0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/extract-headings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ export function embeddedHeadings(metadataCache: MetadataCache, embeds:EmbedCache
}

export function mergeHeadings(headings:HeadingCache[], embeddedHeadings:EmbeddedHeadings) {
console.log(mergeHeadings.name, embeddedHeadings);

const insertHeadings = (h: HeadingCache): HeadingCache []=> {
const offset = h.level;
const eheadings = embeddedHeadings[h.heading]
?.filter((h:HeadingCache) => h.level > 0)
?.filter((h:HeadingCache) => h.level > 1)
.map(tweakOffset(offset));
console.log(eheadings);

return (eheadings) ? [h, ...eheadings] : [h];
};

const patchedHeadings = headings.flatMap(insertHeadings);
console.log(mergeHeadings.name, patchedHeadings);

return {headings:patchedHeadings} as CachedMetadata;
}

Expand Down

0 comments on commit 8638bc0

Please sign in to comment.