You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/slug.ts exposes stripMarkdown, which removes ATX # markers, inline code, image syntax, link wrappers, HTML tags, emphasis markers, emoji, and (as of issue #19) trailing setext underlines from a markdown heading source string.
During issue #19 we verified via DevTools that Obsidian's HeadingCache.heading already returns the plain heading text — underline stripped for setext, and inline-formatting also appears stripped based on the existing paired fixtures (e.g., ## **Bold Heading** is reachable in test-native.md via #Bold%20Heading, suggesting the cache stores "Bold Heading" not "**Bold Heading**").
If the cache already does this work, every production call site (resolver.ts:40, resolver.ts:45, readingModeHandler.ts:39) is feeding pre-stripped text into a stripper. The function is effectively dead code in production; only the unit tests exercise its branches.
Tasks
Inspect app.metadataCache.getFileCache(file).headings in the dev vault for every formatted-heading shape in test-gfm.md / test-native.md: bold, italic, code, image, link, HTML, square-bracket, escaped, setext, emoji. Record what the cache returns for each.
Decide one of:
Trust the cache. Reduce stripMarkdown to a trim (or remove it). Update callers and tests. Document the cache contract relied on.
Keep stripMarkdown as a defensive boundary. Document explicitly why — e.g., planned public API, observed cache leakage in some shape, or platform variance.
Update or remove unit tests in src/slug.test.ts consistent with the chosen direction.
Update plan/observed-behavior-matrix.md and plan/QA-log.md if behavior expectations change.
Acceptance Criteria
app.metadataCache behavior for every heading shape currently exercised by fixtures is documented.
slug.ts either trusts the cache (smaller, simpler) or carries a comment explaining why it doesn't.
Tests align with whichever direction is taken.
npm test passes.
Out of scope
Adding new heading-shape coverage (separate child issues in the P2a epic).
Changing the slug algorithm itself.
References
Issue P2a heading: Setext heading #19 (setext heading) — PR thread documents the production-path tracing that surfaced this concern.
src/slug.ts — current stripMarkdown implementation.
Context
src/slug.tsexposesstripMarkdown, which removes ATX#markers, inline code, image syntax, link wrappers, HTML tags, emphasis markers, emoji, and (as of issue #19) trailing setext underlines from a markdown heading source string.During issue #19 we verified via DevTools that Obsidian's
HeadingCache.headingalready returns the plain heading text — underline stripped for setext, and inline-formatting also appears stripped based on the existing paired fixtures (e.g.,## **Bold Heading**is reachable intest-native.mdvia#Bold%20Heading, suggesting the cache stores"Bold Heading"not"**Bold Heading**").If the cache already does this work, every production call site (
resolver.ts:40,resolver.ts:45,readingModeHandler.ts:39) is feeding pre-stripped text into a stripper. The function is effectively dead code in production; only the unit tests exercise its branches.Tasks
app.metadataCache.getFileCache(file).headingsin the dev vault for every formatted-heading shape intest-gfm.md/test-native.md: bold, italic, code, image, link, HTML, square-bracket, escaped, setext, emoji. Record what the cache returns for each.stripMarkdownto a trim (or remove it). Update callers and tests. Document the cache contract relied on.stripMarkdownas a defensive boundary. Document explicitly why — e.g., planned public API, observed cache leakage in some shape, or platform variance.src/slug.test.tsconsistent with the chosen direction.plan/observed-behavior-matrix.mdandplan/QA-log.mdif behavior expectations change.Acceptance Criteria
app.metadataCachebehavior for every heading shape currently exercised by fixtures is documented.slug.tseither trusts the cache (smaller, simpler) or carries a comment explaining why it doesn't.npm testpasses.Out of scope
References
src/slug.ts— currentstripMarkdownimplementation.src/__tests__/fixtures/test-gfm.md,test-native.md— existing paired-fixture coverage.