mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #60] proper-names should allow different formatting when a URL is used as link text #1897
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#1897
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jerryjappinen on GitHub (May 26, 2017).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/60
Given the following configuration:
I can write this:
Awesome things related to Vue available at GitHub
But not any of this:
Awesome things related to Vue available at github.com
I also tried adding
"github.com"to the configuration both before and after"GitHub"but it didn't help, I still got the error.I believe it's obvious that the latter should also be allowed here. When linking between domains, I quite frequently prefer writing the URL for the user, but will use the link formatting to only write the relevant part and make the link more readable. I might drop the protocol, parameters, trailing slashes and such.
I think
proper-namesshould exempt all URLs and emails. This seems to be the intention as well as the code does not trigger errors from bare URLs, but it still disallows using the URL pattern as a user-facing link text, which probably isn't what we want.@DavidAnson commented on GitHub (May 26, 2017):
Link text is usually meant to be descriptive, so I think the current behavior is a sensible default. But your scenario makes sense as well, so I would be inclined to add an option to exempt link text from this rule to enable it. Would that work?
@jerryjappinen commented on GitHub (May 29, 2017):
That would work for me yeah in this case.
However I still couldn't write "the domain name of GitHub is github.com" anywhere without getting an error, so I wonder if we could handle this in a more generic way. If I do have both
"github.com"and"GitHub"in my configuration, what is the expected behavior? Does the order matter?What I've been writing documentation for a my vue-webpack project template and I noticed that I wanted to do the following:
vue.jsas a file name should be written with lowercase if that's what the file is called. Not a problem since I use code blocks for file names and those are exempt, and there wouldn't be any way for the linter to tell the difference anyhow."vue-router"or"vue-"in my configuration in addition to"Vue". This makes sense if I think about the implementation (dash is a punctuation character), but I think it's actually a common use case (for example many plugins for ESLint have all lowercase names with the string-eslint-included) and there should be a way to handle this.I worked around this issue by enclosing all names that look like this in code blocks, which is fine (ish) for me, but they're not all package names and the same issue comes up with other stylised names or domain names used outside of link texts.
There's probably way more complexity in here that makes sense to try to tackle with this feature of a simple linter, but anyways it's interesting to consider. Perhaps there's an easy solution here somewhere that might involve checking if a string is whitelisted in the config before the linter warns about it, whitelisting all URL patterns or something else.
@DavidAnson commented on GitHub (May 29, 2017):
Interesting scenario! Order should not matter, so I don't think that will help you. I'll create a test file from your examples above and play around with it soon. Some ideas I'll explore are exempting link text and treating period/hyphen as part of the word. I'd rather not support regular expressions, but that may be something else to consider. Thanks again, please let me know if there are other tricky scenarios here!