Skip to content
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

MD051: Add an option to ignore case for automatically-generated heading identifiers #1274

Closed
Stardidi opened this issue Jun 26, 2024 · 5 comments

Comments

@Stardidi
Copy link

The example from the documentation reports MD051/link-fragments: Link fragments should be valid [Expected #heading-name; Actual: #Heading-Name]

# Heading Name

[Link](#Heading-Name)

I expect the behavior as described in the example. The actual logic appears to have a bug.

@DavidAnson
Copy link
Owner

The documentation you link explains why the example you show is reported as a violation:

Link fragments may be handled case-sensitively, so this rule requires fragments to exactly match the GitHub heading algorithm.

@DerGary
Copy link

DerGary commented Aug 21, 2024

Why is this example wrong? It exactly matches the case, so when the link anchor is treated case-sensitive than an exactly matching case should be valid and no violation! Is there a way to change the behaviour of this rule to ignore case or match case exactly??

@DavidAnson
Copy link
Owner

As noted above, this rule matches the GitHub algorithm and that algorithm converts heading text to lower case. Work could be done here to allow mIxEd CaSe, but that would permit inconsistency without adding any functionality.

@DerGary
Copy link

DerGary commented Aug 21, 2024

I understood that it implements the GitHub algorithm but the wording in the documentation that Link fragments may be handled case-sensitively is misleading. For me this reads like this because link fragments can be handled either case sensitive or case insensitive we implemented the GitHub algorithm which handles everyting case sensitive

I will add some background why we stumbled upon this:

We write documentation in markdown and then we use mark to upload the documentation to Atlassian Confluence. Because Confluence is handling anchor links case sensitive this is a bit of a problem because we can't meet both requirements. I already added an issue to mark maybe they can transform the links on generation

@DavidAnson DavidAnson changed the title MD051 incorrectly expects lower cased fragment MD051: Add an option to ignore case for automatically-generated heading identifiers Aug 21, 2024
@Stardidi
Copy link
Author

The parsers we use are also case-sensitive, so that enhancement would help. But they also handle whitespace differently, so maybe not sufficiently...

However I had indeed read this documentation wrong, I read it as different markdown implementations handle case sensitivity differently, so we support both, this was reinforced by may of the other examples being correct markdown and this one being incorrect. Maybe some ✅ and ❌ in the docs could help accentuate when something is valid/invalid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants