I’m working with a group that focuses heavily on personal knowledge management (they use Evernote and similar software). Highlighting is important to them, so I’d like to support the <mark>
html tag in posts through a plugin. I would like to avoid bbcode or using <ins>
if possible. (As an aside, official support for <mark>
could be neat.)
Based on what I could find in these forums and reading through the source code, I landed on the following directive to whitelist the tag in assets/javascripts/lib/discourse-markdown/my-plugin.js.es6
:
// snip
export function setup(helper) {
helper.whiteList([ 'mark' ]);
}
The above works client-side but fails server-side (the tags are stripped out).
(As an aside, you can see I’m also adding a button for it as well. Love how easy that was to do!)
I’m taking an educated guess (based on other forum posts) that this is related to the html_to_markdown
function. This test fails despite the whitelist above:
require 'rails_helper'
require 'html_to_markdown'
describe HtmlToMarkdown do
def html_to_markdown(html, opts={})
HtmlToMarkdown.new(html, opts).to_markdown
end
it "supports <mark>" do
expect(html_to_markdown("<mark>Highlighted</mark>")).to eq("<mark>Highlighted</mark>")
end
end
Failures:
1) HtmlToMarkdown supports <mark>
Failure/Error: expect(html_to_markdown("<mark>Highlighted</mark>")).to eq("<mark>Highlighted</mark>")
expected: "<mark>Highlighted</mark>"
got: "Highlighted"
(compared using ==)
Is this a reasonable pursuit? What am I missing to provide support for this server-side?