Skip to content

feat!: populate canonical headingLevel on read and clamp write-side levels via the shared helper - #58

Merged
Mearman merged 2 commits into
mainfrom
feat/markdown-heading-level
Aug 17, 2026
Merged

feat!: populate canonical headingLevel on read and clamp write-side levels via the shared helper#58
Mearman merged 2 commits into
mainfrom
feat/markdown-heading-level

Conversation

@Mearman

@Mearman Mearman commented Aug 17, 2026

Copy link
Copy Markdown
Member

Two changes, companion to document-schema.js 3.0.0's canonical ContentParagraph.headingLevel field and shared clampHeadingLevel() helper:

  • Reader: lowerHeading now records each heading's own #-depth as ContentParagraph.headingLevel alongside the existing Heading{N} styleId, so a consumer that never learned this package's own styleId spelling still gets the depth as a number. CommonMark headings are already numbered 1-6 by construction, so no inference is needed.
  • Writer: the private clamp-to-6 of a Heading{N} styleId is replaced by document-schema.js's clampHeadingLevel(), giving the ecosystem one heading-range clamp instead of two. The md/heading-level-clamped diagnostic fires exactly as before (both existing tests pass unchanged). headingStyleId, parseHeadingStyleId, and MAX_HEADING_STYLE_LEVEL stay exported unchanged — documents.js and the web app consume the styleId vocabulary; only the clamping logic centralises.

This is deliberately a breaking major: emitted ContentDocuments now carry CONTENT_FORMAT_VERSION 3, incompatible for consumers still validating on schema 2. The earlier 1.4.1 release shipped the same dependency bump as a patch via the sibling-release automation — that was an oversight of the automation, not a decision; this release states the major the bump always warranted.

Closes #54

Generated by Claude Code

document-schema.js 3.0.0 carries CONTENT_FORMAT_VERSION 3 and defines
the canonical ContentParagraph.headingLevel field plus the shared
clampHeadingLevel() helper that the heading-level work in this package
builds on, so the dependency range moves to ^3.0.0 ahead of that.
…evels via the shared helper

readMarkdown's lowering now records each heading's own #-depth as
ContentParagraph.headingLevel -- document-schema.js's canonical,
format-agnostic depth field -- alongside the existing Heading{N}
styleId, so a consumer that never learned this package's own styleId
spelling still gets the depth as a number. writeMarkdown's clamp of a
Heading{N} styleId deeper than 6 now goes through document-schema.js's
clampHeadingLevel() instead of this package's own private clamp, giving
the ecosystem one heading-range clamp; the md/heading-level-clamped
diagnostic fires exactly as before. headingStyleId,
parseHeadingStyleId, and MAX_HEADING_STYLE_LEVEL stay exported
unchanged for the sibling packages consuming the styleId vocabulary --
only the clamping logic centralises.

Closes #54.

BREAKING CHANGE: readMarkdown's emitted ContentDocuments now carry
CONTENT_FORMAT_VERSION 3 and validate against document-schema.js 3;
consumers still validating against schema 2 must move to 3.
@Mearman
Mearman merged commit 32bc2de into main Aug 17, 2026
11 checks passed
@Mearman
Mearman deleted the feat/markdown-heading-level branch August 17, 2026 13:36
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Populate headingLevel on read; switch the write-side clamp to the shared helper

1 participant