Skip to content

Audit stripMarkdown for production-path necessity #114

Description

@RE-codes

Context

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.
  • src/__tests__/fixtures/test-gfm.md, test-native.md — existing paired-fixture coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:investigationTracing or measurement; produces findings, not featuresarea:refactorArchitectural extraction with no behavior change intendedarea:slugGFM slug generationpriority:p3P3: public-release readiness coverage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions