Skip to content

feat(Markdown): add heading links identity foundation - #6911

Merged
cixzhang merged 1 commit into
mainfrom
feat/markdown-heading-links
Oct 3, 2026
Merged

cixzhang merged 1 commit into
mainfrom
feat/markdown-heading-links

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add createMarkdownHeadingLinks(), a standalone opt-in/default-off first-party identity module exported from @astryxdesign/core/Markdown/plugins
  • give every transformed h1–h6 a deterministic Unicode-aware, collision-safe ID, with an optional caller-owned namespace
  • share the same all-depth identity projection with Markdown-derived Outline while preserving root-only Outline selection, released no-plugin behavior, and complete custom-heading anatomy ownership
  • carry normalized module options inside the existing frozen, versioned Symbol.for plugin envelope so compatible duplicate Core copies preserve namespaces
  • recognize only the exact module configuration: compatible same-name generic plugins retain ordinary plugin semantics but cannot affect heading IDs; malformed generic entries use the existing Markdown/Outline readable fallback instead of throwing
  • intentionally add no renderer code in this foundation; its module authority locks the dependent renderer to an honest inline # copy button, no navigation/hash/scroll mutation, canonical useContainerReveal, line-height-sized layout, and overflow-visible coarse hit geometry

Stack

  • foundation: this PR
  • permalink renderer and exact Linux browser evidence: #6915

Attribution

This stack carries forward the inline trailing # permalink direction contributed by Ernest Tien in the superseded #6665. The Changeset credits both contributors; the implementation uses the standalone module architecture and copy-button behavior described above.

Test plan

  • pnpm exec vitest run packages/core/src/Markdown/plugins/headingLinks.test.tsx packages/core/src/Markdown/plugins/headingLinks.ssr.test.tsx packages/core/src/Markdown/Markdown.test.tsx packages/core/src/Markdown/Markdown.public.test.ts packages/core/src/Outline/parseOutlineFromMarkdown.test.ts (142 tests)
  • pnpm --filter @astryxdesign/core typecheck
  • pnpm --filter @astryxdesign/core build
  • built @astryxdesign/core/Markdown/plugins runtime import plus generated declaration/barrel verification
  • focused ESLint on changed TypeScript files
  • pnpm check:knowledge && pnpm check:sync && pnpm check:changesets
  • full repository pre-commit checks

Writing rubric results

  • R1 narration: “foundation patch” and “renderer PR” wording found; rewritten as present-tense module and renderer ownership.
  • R2 research: none in the record; comparison and implementation investigation stay outside the specification.
  • R3 evidence: no pull request, issue, or commit used as evidence or basis.
  • R4 rejected alternatives: three one-line guardrails, each inside its owning decision.
  • R5 change references: two #6665 standing references found; replaced with durable visual and interaction facts.
  • R6 open questions: none.

@cixzhang

@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 3, 2026 9:18pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 3, 2026
@astracat-bot

astracat-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 3, 2026, 9:35 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@cixzhang cixzhang changed the title feat(Markdown): add linkable heading permalinks feat(Markdown): add opt-in heading links plugin Oct 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making linkable Markdown headings opt-in. Preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, keeping authored heading links valid with a sibling permalink, and leaving custom heading renderers in control are a strong basis, and the mechanism for keeping both surfaces on the same IDs is clear.

Approval needs a maintainer to settle the governing spec for this intentional change first. The current Markdown, Outline-from-Markdown, and system records still preserve top-level-only heading identity and treat widening traversal as a separate decision, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace and URL base for plugin-enabled documents. Please have a maintainer provide or update that governing spec — including alignment of all three records for the plugin-enabled carve-out — before this contract is accepted as current.

Independent fixes will still be needed after that decision:

  • The permalink is visible at rest in the exact-head browser evidence (rest opacity 1 where 0 is expected) instead of quiet until hover or focus, and that CI job is red. Please make the rest-hidden state reach the link and re-prove the rest, hover, focus, touch, and forced-colors states.
  • The Outline and system records are not updated in this PR, so they would still contradict the approved plugin-enabled behavior. Please align them, or record why they need no alignment, as part of the maintainer-approved spec update.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making linkable Markdown headings opt-in. Preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, keeping authored heading links valid with a sibling permalink, and leaving custom heading renderers in control are a strong basis, and aligning the proposed wording across the Markdown, Outline, system, and API-admission records in this revision makes the decision clear to evaluate.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity and treat widening traversal as a separate decision, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace and URL base for plugin-enabled documents. Please have a maintainer approve the exact proposed spec text in this PR as that governing update — or state the corrections required — before this contract is accepted as current.

Once that decision is settled, please also make sure the exact-head browser evidence for the new permalink passes for the rest, hover, focus, touch, and forced-colors states, since that proof is still pending.

[Automated review]

@cixzhang cixzhang changed the title feat(Markdown): add opt-in heading links plugin feat(Markdown): add heading links module Oct 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making linkable Markdown headings opt-in. Preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, keeping authored heading links valid with a sibling permalink, and leaving custom heading renderers in control are a strong basis, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace and URL base for plugin-enabled documents, with Core composing the module through an internal seam. Please have a maintainer approve the exact proposed spec text in this PR as that governing update — or state the corrections required — before this contract is accepted as current.

Once that decision is settled, please also make sure the exact-revision browser evidence for the new permalink passes for the rest, hover, focus, touch, and forced-colors states, since that proof is still pending.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making linkable Markdown headings opt-in and for adding a clear copy confirmation to the permalink. Preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, keeping authored heading links valid with a sibling permalink, leaving custom heading renderers in control, and failing soft to native navigation when clipboard access is unavailable are a strong basis, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, a caller-owned namespace and URL base, and copy-on-activation with a check and polite confirmation for plugin-enabled documents, with Core composing the module through an internal seam. Please have a maintainer approve the exact proposed spec text in this PR as that governing update — or state the corrections required — before this contract is accepted as current.

Independent fixes will still be needed after that decision:

  • The permalink is visible at rest in the exact-revision browser evidence (rest opacity 1 where 0 is expected) instead of quiet until hover or focus, and that job stops before proving the later hover, focus, copy, touch, and forced-colors states. Please make the rest-hidden state reach the link and re-prove all of those states, including the fixed-space check, clipboard contents, and fragment navigation.
  • The verified authored size is now 2,232 changed lines, over the review threshold without a cleared exception. Please provide the decomposition and necessity evidence that satisfies the exception once the governing contract is settled, or reduce or split the scope into bounded reviewable parts.

[Automated review]

@cixzhang
cixzhang force-pushed the feat/markdown-heading-links branch from 376e8f3 to 380fb30 Compare October 3, 2026 15:46
@cixzhang cixzhang changed the title feat(Markdown): add heading links module feat(Markdown): add heading links identity foundation Oct 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, leaving custom heading renderers in control, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate, and the focused identity and server-rendering tests pass at this revision.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace for plugin-enabled documents, with Core composing the module through an internal seam. Please have a maintainer approve the exact proposed spec text in this PR as that governing update — or state the corrections required — before this contract is accepted as current.

One independent fix will still be needed after that decision:

  • An entry created by a duplicate Core copy would be silently unrecognized, because its options are stored only in the creating copy, so a consuming copy falls back to released IDs with no diagnostic and Markdown and Outline could disagree if they come from different copies. Please carry recognition on the stable cross-package shape and prove it with a duplicate-copy fixture.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, carrying the namespace on the entry so compatible duplicate Core copies agree, leaving custom heading renderers in control, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate, and the focused identity and server-rendering tests pass at this revision.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace for plugin-enabled documents, with Core composing the module through an internal seam. Please have a maintainer approve the exact proposed spec text in this PR as that governing update - or state the corrections required - before this contract is accepted as current.

One independent fix will still be needed after that decision:

  • A same-name or incompatible heading-links entry currently makes Markdown rendering throw instead of failing soft with a diagnostic and the released heading behavior, so a version-skewed or lookalike entry can take down the whole document. Please route that validation through the existing soft plugin-admission path and prove the Markdown component still renders with matching Outline IDs.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, carrying the namespace on the entry so compatible duplicate Core copies agree, leaving custom heading renderers in control, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate, and the focused identity and server-rendering tests pass at this revision.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace for plugin-enabled documents, with Core composing the module through an internal seam, and locks the future permalink renderer to an honest copy button with canonical reveal behavior and no navigation, hash, or scroll mutation. Please have a maintainer approve the exact proposed spec text in this PR as that governing update - or state the corrections required - before this contract is accepted as current.

One independent fix will still be needed after that decision:

  • A same-name or incompatible heading-links entry currently makes Markdown rendering throw instead of failing soft with a diagnostic and the released heading behavior, so a version-skewed or lookalike entry can take down the whole document. Please route that validation through the existing soft plugin-admission path and prove the Markdown component still renders with matching Outline IDs.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, carrying the namespace on the entry so compatible duplicate Core copies agree, removing incompatible same-name entries in Markdown and Outline instead of crashing, leaving custom heading renderers in control, and collecting the contract in a dedicated module record with delegating edits in the surrounding records makes the decision clear to evaluate, and the focused identity and server-rendering tests pass at this revision.

Approval needs a maintainer to update the existing governing spec for this intentional change first. The current records on the main branch still preserve top-level-only heading identity, treat widening traversal as a separate decision, and limit first-party plugins to the public protocol with no privileged capability, while this proposal adds depth-first nested IDs, Unicode fragments, and a caller-owned namespace for plugin-enabled documents, with Core composing the module through an internal seam, and locks the future permalink renderer to an honest copy button with canonical reveal behavior and no navigation, hash, or scroll mutation. Please have a maintainer approve the exact proposed spec text in this PR as that governing update - or state the corrections required - before this contract is accepted as current.

One independent fix will still be needed after that decision:

  • An incompatible or same-name heading-links entry is dropped in Markdown and Outline with no diagnostic, so a caller silently loses the intended namespace and nested targets, and the public parser entrypoint still runs a lookalike transform instead of dropping it, so parsed and rendered documents can diverge. Please report the dropped entry through the existing diagnostic path and apply the same removal consistently across Markdown, Outline, and parser entrypoints, with tests for that parity.

[Automated review]

@cixzhang
cixzhang force-pushed the feat/markdown-heading-links branch from 4d743a4 to 07292f2 Compare October 3, 2026 21:02
@cixzhang

cixzhang commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 07292f2

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, carrying the namespace on the entry so compatible duplicate Core copies agree, treating only the exact module configuration as heading links while malformed entries fail soft instead of throwing, and leaving custom heading renderers in control makes this a clean foundation, and the focused identity, Markdown, Outline, and server-rendering tests pass at this revision along with typecheck and the repository knowledge, sync, and changeset checks.

The governing spec question is now settled for this revision: the proposed module record and its delegating edits carry exact-head owner approval, so the depth-first nested IDs, Unicode fragments, caller-owned namespace, and internal projection seam are accepted as the governing contract for plugin-enabled documents, with the future permalink renderer locked to an honest copy button with canonical reveal behavior and no navigation, hash, or scroll mutation. No blocking defect remains in this foundation; the renderer itself still belongs in the dependent follow-up with its own browser evidence.

[Automated review]

@cixzhang
cixzhang force-pushed the feat/markdown-heading-links branch from 07292f2 to 7a57544 Compare October 3, 2026 21:14
@cixzhang

cixzhang commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 7a57544

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting linkable Markdown headings into this identity foundation. Keeping it opt-in and default-off, preserving released no-plugin output, sharing one heading allocator between Markdown and Outline through the same plugin entry, carrying the namespace on the entry so compatible duplicate Core copies agree, treating only the exact module configuration as heading links while malformed entries fail soft instead of throwing, and leaving custom heading renderers in control makes this a clean foundation, and the focused identity, Markdown, Outline, and server-rendering tests pass at this revision along with typecheck and the repository knowledge, sync, and changeset checks.

The governing spec question is now settled for this revision: the proposed module record and its delegating edits carry exact-head owner approval, so the depth-first nested IDs, Unicode fragments, caller-owned namespace, and internal projection seam are accepted as the governing contract for plugin-enabled documents, with the future permalink renderer locked to an honest copy button with canonical reveal behavior and no navigation, hash, or scroll mutation. No blocking defect remains in this foundation; the renderer itself still belongs in the dependent follow-up with its own browser evidence.

[Automated review]

@cixzhang
cixzhang merged commit d69321e into main Oct 3, 2026
45 checks passed
@github-actions
github-actions Bot deleted the feat/markdown-heading-links branch October 4, 2026 08:06
cixzhang pushed a commit that referenced this pull request Oct 21, 2026
<!-- template: bug-fix.md -->

## User impact

An app that builds Astryx from source with the documented Next.js setup, but sets no browserslist or targets a browser without Unicode property escapes (such as Safari 11), fails `next build --webpack` with `Unknown property: L` (also `Zs`, `Letter`). The errors point at `Avatar.tsx`, `Markdown/parser.ts` and `Markdown/plugins/headingLinks.ts`, package source the app cannot change, and come from both the PostCSS pass and the JavaScript compile. Any import from the package root reaches them.

## Problem and solution fit

- Why it fails: with no targets, or old ones, `next/babel`'s preset-env rewrites every `\p{…}` regex literal with transform-unicode-property-regex. Next's bundled copy of that transform loads `regenerate-unicode-properties` at runtime, which Next does not ship, so it throws (Next 16.3.6 and 16.4.2 alike).
- Why it harms the task: the throw stops the whole build.
- Why that matters: the app cannot fix it in its own code, and the error names a Unicode property, not the missing target.

## Expected behavior and authority

This is a regression of a settled case. #5450 hit this failure in `NumberInput/numberParser.ts` and builds those expressions with `new RegExp(...)`; its comment records why, and notes that property escapes need no transform in any browser this package supports. #6698, #6911 and #7051 later added four new literals and reintroduced it.

## Smallest restoration

- The four literals become `new RegExp(...)` with the same pattern and flags, built once at module load as before.
- Each site's comment names the cause and when a literal is safe again: once Next's bundled Babel ships the Unicode data.
- A source-build test fails when a Core module writes a property escape as a regex literal.

## Evidence

- Reproduction before the change: a clean registry install of main's documented Next.js example (`apps/example-nextjs-source`, hoisted, browserslist removed). `next build --webpack` fails in the PostCSS pass (`Avatar.tsx: Unknown property: L`) and in the JavaScript compile (`Unknown property: L`, `Zs`, `Letter` from the three files).
- Result after the change: the same install, with this change applied to Core's source, compiles and prerenders, and all 226 rendered class names have a rule in the emitted CSS.
- Representative unchanged path: the Avatar and Markdown suites pass unchanged.
- Regression test or other mutation-sensitive proof: `unicodePropertyEscapes.source-build.test.mjs` fails on main listing the four literals, and passes here.

## Scope

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- `pnpm exec vitest run --project ui packages/core/src/Avatar packages/core/src/Markdown packages/core/src/unicodePropertyEscapes.source-build.test.mjs`: 50 files, 1,158 tests pass (the new test alone fails on main).
- `next build --webpack` on the clean install, no browserslist: fails on main in both passes; passes with this change (226 of 226 rendered classes have a rule).
- `pnpm -F @astryxdesign/core typecheck`, ESLint and Prettier on the touched files, `pnpm check:repo`, changeset coverage: pass.

This branch was successfully deployed

1 active deployment
Preview — 7a575447 Deployed Oct 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant