Closed kajmagnus closed 4 years ago
Linkifier just returns a list of ranges, and you can use as many as you wish. Option here is not needed.
For markdown you can create post-processing "plugin" and drop undesired link.
In short: that's all doable without additional options in mainstream.
@puzrin Thanks! This makes me wonder if Markdown-it knows how Linkify-it works, and looks at the list of ranges returned by Linkify-it? And uses this to create real links in the generated html?
Because otherwise I'd be confused about how the actual real-link-insertion happens (if Linkify-it only returns a list of ranges, but doesn't actually alter the generated html).
https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js
Please, inspect sources at least by diagonal, prior to ask any questions. I can help with real difficulties, but prefer avoid basic-level questions (time constrains).
@puzrin Thanks for the link — don't think I would have found that file since it's in a different repository (in markdown-it
not linkify-it
)
What are your thougts about if Linkify-it had something like a
linkLimit
setting that, if it was say 5, meant only the 5 first link looking things got converted to<a href=...>
links? Remaining links would stay plain-text only.Could that make it simpler to create more user friendly software built on Markdown-it and Linkify-it? Or is this a weird idea?
Background: I use Markdown-it and Linkify-it for processing CommonMark text people post to forum software I'm building, Talkyard. I've restricted the number of links in posts by not-logged-in ("guest") users and new users to something like only 3 or 5 links (and for full members, and trusted members, it's more and more), so spammers cannot post too many annoying links. Also, Talkyard checks all links with Google Safe Browsing API and I'd think it's not a good idea to accept an "unlimited" number of links in a comment by someone, and then ask Safe Browsing about all those links.
However, if someone posts too many links, Talkyard says "Error. Too many links. Please remove some links" — and that's not so user friendly. So I started thinking: Maybe a max-num-links setting in Linkify-It could make sense — any thoughts about this? Maybe there're other better solutions
Thanks Puzrin for creating this software :- )