What method is used by Discourse to identify urls in post body and make it clickable?. I tried going through the codebase. But still no luck.
It uses markdown-it’s linkify extension.
2 Likes
Thank you @notriddle
The above is used for client, are there any similar ways for ruby on rails ?
It actually also uses linkify-it
.
I could be wrong, AFAIK the PrettyText
module is used to cook raw content into markdown: it essentially utilizes mini_racer
to embed the V8 JavaScript Engine into Ruby, and runs exactly the same scripts as the client.
6 Likes
I guess you want to extract all the links inside the post for the feature Preventing malicious linking - #27 by Sudaraka. You can get it simply by doc.css("a[href]")
using Nokogiri module.
5 Likes
Thank you @xrav3nz and @vinothkannans . Yes @vinothkannans I was trying to find the optimal method for extracting all urls in the post
1 Like