Fix linkify example code in README #722
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates an example code of Linkify in README. Because it does not work correctly.
Problem
The example said "disables .py as top level domain" by
md.linkify.tlds('.py', false)
, but it is not correct.It actually disables all top-level domains, except
..py
. So, with the configuration, linkify doesn't convertfoo.py
to a link, but it also doesn't convertgithub.com
and so on. But it convertsfoo..py
to a link accidentally. 😂Why it happens
The example misunderstood the behavior of linkify-it's
tlds
function.http://markdown-it.github.io/linkify-it/doc/#LinkifyIt.prototype.tlds
The second argument is "keepOld".
So, if it is false, the function replaces the whole of the current list with
['.py']
. It means it only allows..py
domain.Solutoon
I replaced the wrong example with another example that disables converting emails.
I think disabling email conversion is not a rare setting, so it is appropriate.
By the way, I couldn't find an easy way to disable
.py
TLD. I guess we need the following code for this, but it isn't smart for me.So I changed the example from disabling
.py
.