Skip to content

docs-infra: Route generation script ignores custom heading ID syntax #67200

@lacolaco

Description

@lacolaco

Describe the problem that you experienced

The route generation script (adev/scripts/routes/generate-routes.mts) uses a simplified logic to generate heading IDs from markdown headings. However, the markdown pipeline (adev/shared-docs/pipeline/shared/marked/transformations/heading.mts) supports a custom ID syntax {#custom-id} for explicit anchor IDs.

This inconsistency causes generated routes to differ from the actual anchor IDs in the rendered documentation when custom IDs are used. This is particularly problematic for localized documentation (e.g., angular/angular-ja) where custom IDs are used to maintain stable links across translations.

Enter the URL of the topic with the problem

N/A (Build/Generation issue)

Describe what you were looking for in the documentation

I expected the route generation process to respect the same heading ID rules as the markdown rendering pipeline.

Describe the actions that led you to experience the problem

  1. Create a markdown file with a heading using a custom ID: ## My Heading {#my-custom-id}.
  2. Run the route generation script.
  3. Observe that the generated route uses my-heading-my-custom-id (derived from text) instead of my-custom-id.

Describe what you want to experience that would fix the problem

The generated route for a heading with {#custom-id} should be #my-custom-id, not #my-heading-my-custom-id. The logic for extracting heading IDs should be shared between the route generation script and the markdown pipeline to ensure consistency.

Add a screenshot if that helps illustrate the problem

(None)

If this problem caused an exception or error, please paste it here

(None)

If the problem is browser-specific, please specify the device, OS, browser, and version

(None)

Provide any additional information here in as much as detail as you can

There is a TODO comment in adev/scripts/routes/generate-routes.mts:
// TODO: refactor so this function is shared with the generation pipeline (adev/shared-docs/pipeline/shared/marked/transformations/heading.mts)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: docs-infraAngular.dev application and infrastructure

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions