Linkify words in post


(Sam Saffron) #89

I just made it wiki, so go ahead :innocent:


Is there any way to linkify words in quotes? It seems whenever a linkified word is in a quote, the linkify CSS class is stripped.

(Daniel Hollas) #91

Yes, this was an intentional decision, we thought that quote indicate that no magic should be applied. You can easily modify the code to fix that though: Just include the quotes in variables leftWordBoundary and rightWordBoundary like this

  let leftWordBoundary = "(\\s|[\"\'\\([{]|^)";
  let rightWordBoundary = "([\"\':.;,!?…\\]})]|\\s|$)";

Let me know if this works or if you need more guidance.


it seems the issue is rather that when quoting a text passage with a linkified word, it picks up the link as a regular one and adds it in markdown which obviously does not include any CSS class

so to display the link in the quote properly, the markdown link has be either stripped when pressing β€œquote button”. the workaround provided would help then.

(Daniel Hollas) #93

Oh, I misunderstood. Do you mean quoting like this :arrow_double_up:? Or something else? What do you mean by β€œquote” button? Could you be more specific what do you mean by quoting and step by step instructions how to reproduce?

I did a test on my site and it seems to me that it works just fine inside the quoted text. (and btw: this should be largely independent of any CSS).

As long as the text is not inside the <a>, <pre>, <iframe> or <code> tags, it should work.

If this theme would be installed here in meta we could test it, but it is probably not.

EDIT: Indeed, when you quote the text with autolink, it is converted to a proper full markdown link. But I would call that a win. What are the downsides of this behaviour?

(Daniel Hollas) #94

Well played, Sam, well played. :face_with_raised_eyebrow:

I took a stab at it, please have a look and clean up if needed.

(Daniel Hollas) #95

One more small PR :angel:

I added a new settings for user-selectable excluded HTML tags. For example, in our case we do not want anything inside the header tags <hX> to be linkified.

The default is the same as before i.e. <pre> and <code>.

Exclusion of <a> and <iframe> is hardcoded and cannot be changed by the settings.