Skip to content

Refactor anchor link handling for badges

Sarah German requested to merge 1700-badge-anchors into main

What does this MR do and why?

Refactors how we drop badge content from anchor links on headers.

The previous approach was to match specific words in the badges, like "premium self" and drop known pairs. This no longer works well as we've introduced badges that are more likely to appear in regular header text, or outside of known pairs that we can more confidently match.

In this MR, we change the logic to instead find text in markdown strong tags **(like this)** within headers, and we match against that when truncating the anchors, rather than the list of badge words. We can be more certain that text formatted **(like this)** is a badge than we can by looking for strings like "all" or "beta."

This will fix the "Experiment" and "Beta" anchor links on this page: https://docs.gitlab.com/ee/policy/experiment-beta-support.html

Closes #1700 (closed)

Screenshots, screen recordings, or links to review app

On the review app, or locally, check some anchors that are broken on production:

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Closes #1700 (closed)

Edited by Sarah German

Merge request reports