mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 02:23:40 +08:00
234694b50f
This adds the markdown.it engine to Discourse. https://github.com/markdown-it/markdown-it As the migration is going to take a while the new engine is default disabled. To enable it you must change the hidden site setting: enable_experimental_markdown_it. This commit is a squash of many other commits, it also includes some improvements to autospec (ability to run plugins), and a dev dependency on the og gem for html normalization.
19 lines
527 B
JavaScript
19 lines
527 B
JavaScript
import { censor } from 'pretty-text/censored-words';
|
|
import { registerOption } from 'pretty-text/pretty-text';
|
|
|
|
registerOption((siteSettings, opts) => {
|
|
opts.features.censored = true;
|
|
opts.censoredWords = siteSettings.censored_words;
|
|
opts.censoredPattern = siteSettings.censored_pattern;
|
|
});
|
|
|
|
export function setup(helper) {
|
|
|
|
if (helper.markdownIt) { return; }
|
|
|
|
helper.addPreProcessor(text => {
|
|
const options = helper.getOptions();
|
|
return censor(text, options.censoredWords, options.censoredPattern);
|
|
});
|
|
}
|