mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
Feature: CommonMark support
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.
This commit is contained in:
parent
6048ca2b7d
commit
234694b50f
57 changed files with 11146 additions and 96 deletions
|
@ -20,6 +20,23 @@ registerOption((siteSettings, opts) => {
|
|||
opts.features.details = true;
|
||||
});
|
||||
|
||||
const rule = {
|
||||
tag: 'details',
|
||||
before: function(state, attrs) {
|
||||
state.push('bbcode_open', 'details', 1);
|
||||
state.push('bbcode_open', 'summary', 1);
|
||||
|
||||
let token = state.push('text', '', 0);
|
||||
token.content = attrs['_default'] || '';
|
||||
|
||||
state.push('bbcode_close', 'summary', -1);
|
||||
},
|
||||
|
||||
after: function(state) {
|
||||
state.push('bbcode_close', 'details', -1);
|
||||
}
|
||||
};
|
||||
|
||||
export function setup(helper) {
|
||||
helper.whiteList([
|
||||
'summary',
|
||||
|
@ -29,5 +46,11 @@ export function setup(helper) {
|
|||
'details.elided'
|
||||
]);
|
||||
|
||||
helper.addPreProcessor(text => replaceDetails(text));
|
||||
if (helper.markdownIt) {
|
||||
helper.registerPlugin(md => {
|
||||
md.block.bbcode_ruler.push('details', rule);
|
||||
});
|
||||
} else {
|
||||
helper.addPreProcessor(text => replaceDetails(text));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue