Skip to content

BREAKING CHANGE: Don't allow dots (.) in slug #1093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Apr 11, 2025

Context

Currently, dots (.) are allowed in slugs. This means generated anchors also contain slugs.

If you create a header like

## 1. Install

Then it's anchor will be #1.-install.

However, IDE's are expecting the anchor #1-install.

image

Reported by @flobernd

Changes

By removing the . from the allowed chars of Slugify, the correct anchor is generated.

@reakaleek reakaleek requested a review from a team as a code owner April 11, 2025 07:30
Copy link

Label error. Requires exactly 1 of: automation, breaking, bug, changelog:skip, chore, ci, dependencies, documentation, enhancement, feature, fix, redesign. Found:

@reakaleek reakaleek self-assigned this Apr 11, 2025
@reakaleek reakaleek changed the title Don't allow dots (.) in slug BREAKING CHANGE: Don't allow dots (.) in slug Apr 11, 2025
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

+1 on removing dots.

var slug = slugTarget.Slugify();
var slug = anchor ?? header.Slugify();
if (slug.Contains('$'))
slug = HeadingAnchorParser.InlineAnchors().Replace(slug, "");
Copy link
Member

Choose a reason for hiding this comment

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

I do think we want to always sanitize anchor or header through Slugify().

What was the usecase for removing it from anchor?

Copy link
Member Author

@reakaleek reakaleek Apr 11, 2025

Choose a reason for hiding this comment

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

Sorry, currently working on this. Switched back to draft.

But I was thinking of limiting the blast radius.

If someone creates a custom anchor, we might want to maintain the dot.

Copy link
Member

Choose a reason for hiding this comment

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

I think having uniformity in our slugging beats allowing dots in custom anchors.

The main reason might be version numbers but they look okay without dots too e.g

#whats-new-in-8.18

vs

#whats-new-in-8-18

I actually prefer the latter visually too.

Copy link
Member Author

@reakaleek reakaleek Apr 11, 2025

Choose a reason for hiding this comment

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

The slight problem here is that it seems like the default markdown behaviour is to strip the . and not replace it with -.

Screenshot 2025-04-11 at 11 52 55

Hence, it would become #whats-new-in-818

Copy link
Member

Choose a reason for hiding this comment

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

ahh but that discrepancy exists today already no?

If someone writes

## Whats new in 8.18

We slug to: whats-new-in-8-18 today?

## Whats new in 8.18 [whats-new-in-8.18]

I do think that should also be sanitized the same way to whats-new-in-8-18.

We shouldn't take anchors verbatim and having two sanitation rules is a bit suprising to writers IMO.

Copy link
Member

Choose a reason for hiding this comment

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

  • The numbering gets removed (maybe this is intended?)
  • As a consequence, the anchor is generated differently which breaks the navigation functionality (clicking on the navbar link does nothing)

Copy link
Member Author

Choose a reason for hiding this comment

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

💩

Copy link
Member Author

Choose a reason for hiding this comment

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

One problem I just thought of is the authoring experience.

It will be confusing if you set a custom anchor and then it's sanitized.

E.g.

If I add the custom anchor #whats-new-in-8.0 I would expect it to stay like that.

It could be confusing to see that it changed to #whats-new-in-8-0.

Maybe the best way is to actually to discourage dots (.) in anchors and make it error?

Copy link
Member

Choose a reason for hiding this comment

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

We need to sanitize custom anchors anyhoo e.g #What's-new-in-8.0 we can not take it verbatim. The sanitization is not surprising to me but thats subjective :)

We could hint if custom anchors end up different after sanitization?

Copy link
Member Author

Choose a reason for hiding this comment

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

@flobernd #1094 should fix the bug you reported.

@reakaleek reakaleek marked this pull request as draft April 11, 2025 08:45
@reakaleek
Copy link
Member Author

Won't do. The assembler build emits thousands of errors from both normal content and generated content. Hence, it's not feasible to continue this.

@reakaleek reakaleek closed this Apr 11, 2025
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.

3 participants