Skip to content

fix(editor): ensure anchor does not include variable - #1588

Draft
Alexander6060 wants to merge 1 commit into
nextfrom
alex3/cx-3777-ignore-custom-variables-when-generating-heading-anchors
Draft

fix(editor): ensure anchor does not include variable#1588
Alexander6060 wants to merge 1 commit into
nextfrom
alex3/cx-3777-ignore-custom-variables-when-generating-heading-anchors

Conversation

@Alexander6060

@Alexander6060 Alexander6060 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
🎫 Resolve CX-3777

Related to -> https://github.com/readmeio/readme/pull/20277

🎯 What does this PR do?

  • Excludes modern ({user.name}) and legacy (<<name>>) custom variables from generated heading anchors, keeping anchors stable regardless of variable values.
  • Falls back to the variable name when a heading contains only variables and preserves duplicate-anchor numbering.

🧪 QA tips

  • Run npm test -- __tests__/transformers/mdxish-heading-slugs.test.ts --run.
  • Confirm ## Hello {user.name} and ## Hello <<name>> generate hello-.
  • Confirm variable-only and duplicate headings still generate usable, unique anchors.

📸 Screenshot or Loom

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b8197c9-31ea-40a8-adff-0f1f03564a73

📥 Commits

Reviewing files that changed from the base of the PR and between 919f103 and 91a036d.

📒 Files selected for processing (2)
  • __tests__/transformers/mdxish-heading-slugs.test.ts
  • processor/transform/mdxish/heading-slugs.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:


Walkthrough

Heading slug generation now excludes valid variable nodes from normal heading text while preserving separators. For headings with no remaining text, the generator uses variable names as fallback slug content. Duplicate fallback slugs receive suffixes. Tests cover MDX and legacy variables, JSX variables, numeric and underscore names, invalid hyphenated expressions, and deduplication across different variables.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

__tests__/transformers/mdxish-heading-slugs.test.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Error while loading rule '@vitest/unbound-method': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.
Parser: /node_modules/@typescript-eslint/parser/dist/index.js
Occurred while linting /tests/transformers/mdxish-heading-slugs.test.ts
at throwError (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:40:11)
at getParserServices (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:29:9)
at create (/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unbound-method.js:138:55)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at create (/node_modules/@vitest/eslint-plugin/dist/index.cjs:6355:35)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at createRuleListeners (/node_modules/eslint/lib/linter/linter.js:895:21)
at /node_modules/eslint/lib/linter/linter.js:1066:110
at Array.forEach ()
at runRules (/node_modules/eslint/lib/linter/linter.js:1003:34)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eaglethrost
eaglethrost marked this pull request as draft August 17, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant