showdown/src/subParsers/strikethrough.js
Estevao Soares dos Santos 5c50675cca fix(simpleAutoLinks): URLs with emphasis/strikethrough are parsed
correctly

When a user enters a URL with emphasis or strikethrough, the html output
were incorrect.
Now, URLs inside emphasis or strikethrough are parsed corerctly

Closes #347
2017-02-26 19:13:52 +00:00

19 lines
619 B
JavaScript

showdown.subParser('strikethrough', function (text, options, globals) {
'use strict';
function parseInside (txt) {
if (options.simplifiedAutoLink) {
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
}
return '<del>' + txt + '</del>';
}
if (options.strikethrough) {
text = globals.converter._dispatch('strikethrough.before', text, options, globals);
text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
text = globals.converter._dispatch('strikethrough.after', text, options, globals);
}
return text;
});