I want to create custom markdown tags using showdown.js
such that:
==highlighted text==
renders:
<mark>highlighted text</mark>
Using the twitter
extension as a baseline, I've been trying:
// #highlighted# syntax
{
type: 'lang',
regex: '\\B(\\\\)?==([\\S]+)\\b',
replace: function (match, leadingSlash, highlighted) {
// Check if we matched the leading \ and return nothing changed if so
if (leadingSlash === '\\') {
return match;
} else {
return '<mark>' + highlighted + '</mark>';
}
}
},
But this only lets me highlight single words, e.g.
I'd like to use ==
similar to **
.
I assume the problem is the regex but can't seem to nail it. Can someone advise?
If I understand question correctly you can use this simple regex:
regex: "==\\s*(.+?)\\s*==";
and use matched group #1.