[GH-ISSUE #606] MD051 option for space replacement character #477

Closed
opened 2026-03-03 01:27:15 +03:00 by kerem · 4 comments
Owner

Originally created by @nschonni on GitHub (Oct 12, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/606

Currently the space is swapped by -, I think there have been one or to other parsers that flagged that they use _ instead, so it might help to keep the default, but allow overriding this.

This is the current replacement, that would need to take the option:

.replace(/ /gu, "-")

I was wondering if some larger configurability might be needed for the different anchor link patterns, but maybe this would be enough

Originally created by @nschonni on GitHub (Oct 12, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/606 Currently the space is swapped by `-`, I think there have been one or to other parsers that flagged that they use `_` instead, so it might help to keep the default, but allow overriding this. This is the current replacement, that would need to take the option: ```js .replace(/ /gu, "-") ``` I was wondering if some larger configurability might be needed for the different anchor link patterns, but maybe this would be enough
kerem 2026-03-03 01:27:15 +03:00
Author
Owner

@DavidAnson commented on GitHub (Dec 8, 2022):

I clarified that this rule implements the GitHub anchor algorithm here: https://github.com/DavidAnson/markdownlint/blob/next/doc/md051.md

I am going to close this issue as I don't think I will change the current behavior unless it is to support another algorithm entirely or perhaps make it configurable someday. So far, neither has seemed necessary.

<!-- gh-comment-id:1341882274 --> @DavidAnson commented on GitHub (Dec 8, 2022): I clarified that this rule implements the GitHub anchor algorithm here: https://github.com/DavidAnson/markdownlint/blob/next/doc/md051.md I am going to close this issue as I don't think I will change the current behavior unless it is to support another algorithm entirely or perhaps make it configurable someday. So far, neither has seemed necessary.
Author
Owner

@DavidAnson commented on GitHub (Dec 8, 2022):

Update: A request for a different algorithm entirely: https://github.com/DavidAnson/markdownlint/issues/570

<!-- gh-comment-id:1341888740 --> @DavidAnson commented on GitHub (Dec 8, 2022): Update: A request for a different algorithm entirely: https://github.com/DavidAnson/markdownlint/issues/570
Author
Owner

@nschonni commented on GitHub (Dec 8, 2022):

Yes, this is a lighter version compared to that issue. The main use case I have for this is coming from the mdn/content repo. Since they migrated from a Wiki format to markdown, they maintained the _ style replacement

<!-- gh-comment-id:1341906289 --> @nschonni commented on GitHub (Dec 8, 2022): Yes, this is a lighter version compared to that issue. The main use case I have for this is coming from the mdn/content repo. Since they migrated from a Wiki format to markdown, they maintained the `_` style replacement
Author
Owner

@connorads commented on GitHub (Feb 24, 2023):

I've also faced similar issue with MD051 and Backstage TechDocs which replaces  -  (space dash space) with - (dash)

Interesting that MDN have chosen to disable MD051 because of different algorithm in their docs system yari
https://github.com/mdn/content/blob/main/.markdownlint-cli2.jsonc#L117-L118

Would be great to be able to configure this somehow as MD051 does great work to keep them links working!

In the meantime I've been looking for a way to stop people from using - in headings.

<!-- gh-comment-id:1443510590 --> @connorads commented on GitHub (Feb 24, 2023): I've also faced similar issue with `MD051` and Backstage TechDocs which replaces ` - ` (space dash space) with `-` (dash) Interesting that MDN have chosen to disable `MD051` because of different algorithm in their docs system yari https://github.com/mdn/content/blob/main/.markdownlint-cli2.jsonc#L117-L118 Would be great to be able to configure this somehow as `MD051` does great work to keep them links working! _In the meantime I've been looking for a way to stop people from using `-` in headings._
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#477
No description provided.