-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Do not include href if href without protocol is same as text in link #271
Comments
Thank you. |
hello @KillyMXI, |
Hello, The set of options for anchor formatter is pretty chaotic. I thought to use this issue as an opportunity to come up with something better, to minimize the number of deprecated options I'd have to support with gradual change. The design isn't crystallized yet. |
I strongly disagree with the expectation described. Removing the protocol is wrong. It could be http, https, ftp, mailto, etc. Instead, I suggest only skipping if the reference and the text are exactly the same: input - please use <a href="http://www.google.com">www.google.com</a> to search
Expected: "please use www.google.com [http://www.google.com] to search" (current state) input - please use <a href="http://www.google.com">http://www.google.com</a> to search
-Received: "please use http://www.google.com [http://www.google.com] to search"
+Expected: "please use http://www.google.com to search" EDIT: forgot to say, that this is already the case with |
Problem to solve
What kind of problem you were trying to solve when you realized there is a missing feature?
replace old custom regex for proper lib but try to not make visual changes.
so missing feature:
add option to skip adding href as text if href without protocol is same as text of link
input -
please use <a href="http://www.google.com">www.google.com</a> to search
Expected: "please use www.google.com to search"
Received: "please use www.google.com (http://www.google.com) to search"
if text is not same as href without protocol then add href
input -
please use <a href=\"http://www.google.com\">gugl</a> to search
Expected and Received: "please use gugl (http://www.google.com) to search"
What works
How close to your goal you can currently get?
see example,
now we have custom anchor formatter, but its code duplication from lib (whole
formatAnchor
func) which is not good and i think this option is handyWhat is missing
What prevents you from achieving your goal?
more robust
hideSameLink
optionHow the missing feature should be implemented
Explain any technical details here.
in
formatAnchor
parse href without protocol and compare it with text case-insensitiveconst hideSameLink = formatOptions.hideLinkHrefIfSameAsText && (getHrefWithoutProtocol(href) === text.toLowerCase() || href === text);
or change options
hideSameLink
to have multiple "hide" levelsor add its own options
Bigger picture
Do you think this feature has different uses? Is there a better way to do it? What other options you've considered?
The text was updated successfully, but these errors were encountered: