Feature: Change markdown engine to markdown it

This commit removes the old evilstreak markdownjs engine.

- Adds specs to WhiteLister and changes it to stop using globals
    (Fixes large memory leak)
- Fixes edge cases around bbcode handling
- Removes mdtest which is no longer valid (to be replaced with
    CommonMark)
- Updates MiniRacer to correct minor unmanaged memory leak
- Fixes plugin specs
This commit is contained in:
Sam Saffron
2017-07-14 08:27:28 -04:00
committed by Sam
parent 9e03fae26c
commit d0c5205a52
123 changed files with 1181 additions and 7872 deletions

View File

@ -1,25 +1,3 @@
import { registerOption } from 'pretty-text/pretty-text';
function insertDetails(_, summary, details) {
return `<details><summary>${summary}</summary>${details}</details>`;
}
// replace all [details] BBCode with HTML 5.1 equivalent
function replaceDetails(text) {
text = text || "";
while (text !== (text = text.replace(/\[details=([^\]]+)\]((?:(?!\[details=[^\]]+\]|\[\/details\])[\S\s])*)\[\/details\]/ig, insertDetails)));
// add new lines to make sure we *always* have a <p> element after </summary> and around </details>
// otherwise we can't hide the content since we can't target text nodes via CSS
return text.replace(/<\/summary>/ig, "</summary>\n\n")
.replace(/<\/details>/ig, "\n\n</details>\n\n");
}
registerOption((siteSettings, opts) => {
opts.features.details = true;
});
const rule = {
tag: 'details',
before: function(state, attrs) {
@ -46,11 +24,7 @@ export function setup(helper) {
'details.elided'
]);
if (helper.markdownIt) {
helper.registerPlugin(md => {
md.block.bbcode_ruler.push('details', rule);
});
} else {
helper.addPreProcessor(text => replaceDetails(text));
}
helper.registerPlugin(md => {
md.block.bbcode_ruler.push('details', rule);
});
}