Whitelist <mark> tags

I’d like to be able to use <mark> tags in posts to highlight bits of text, especially in quoted language.

Is this something I should potentially take to markdown-it directly?

7 Likes

I think that Discourse could allow the <mark> HTML tag to be used in posts through a fairly small change to the core Discourse code. Getting markdown to support mark would be great too. I see a discussion on their forum about it here: A proposal to support the <mark> tag with Markdown - Extensions - CommonMark Discussion.

6 Likes

I went digging around the repo with git grep markdown-it, but got too many results to pinpoint where to propose a patch.

2 Likes

I recall that Discourse already passes through <ins> and <del>.

Those strike me as vewyvery close to <mark>.

3 Likes

Are you just wanting to be able to use the <mark> HTML tag? If so, I think it just needs to get added to a list of allowed tags in the Discourse code. Someone from the dev team should know which file needs to get updated.

2 Likes

Yup, it’s app/assets/javascripts/pretty-text/addon/allow-lister.js. We should probably also make sure to ship some reasonable default CSS.

4 Likes

Can you share a screenshot of what <mark> would look like? We know what <ins> and <del> look like… ins and del.

Just trying to understand the goal.

3 Likes
background-color: yellow;

IIRC this is more or less as stands in many user-agent default styles.

5 Likes

I suppose that seems benign enough, and we have precedent in the form of <ins> and <del>… what do you think @sam @eviltrout?

4 Likes

Seems easy and fine @techAPJ can sort it next week

3 Likes

Done via:

https://github.com/discourse/discourse/commit/85c4e8fd32fdf61a2987c2b181661bbd7d203913

This text is <mark>highlighted</mark>.

This text is highlighted.

11 Likes

This topic was automatically closed after 6 days. New replies are no longer allowed.