FIX: prevents md processing if plugin is disabled (#31)

This commit is contained in:
Joffrey JAFFEUX 2021-04-23 14:05:21 +02:00 committed by GitHub
parent 152a7b5c60
commit c925f7e2a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -164,19 +164,20 @@ export function setup(helper) {
return; return;
} }
let enable_asciimath;
helper.registerOptions((opts, siteSettings) => { helper.registerOptions((opts, siteSettings) => {
opts.features.math = siteSettings.discourse_math_enabled; opts.features.math = siteSettings.discourse_math_enabled;
enable_asciimath = siteSettings.discourse_math_enable_asciimath; opts.features.asciimath = siteSettings.discourse_math_enable_asciimath;
}); });
helper.registerPlugin((md) => { helper.registerPlugin((md) => {
if (enable_asciimath) { if (md.options.discourse.features.math) {
if (md.options.discourse.features.asciimath) {
md.inline.ruler.after("escape", "asciimath", asciiMath); md.inline.ruler.after("escape", "asciimath", asciiMath);
} }
md.inline.ruler.after("escape", "math", inlineMath); md.inline.ruler.after("escape", "math", inlineMath);
md.block.ruler.after("code", "math", blockMath, { md.block.ruler.after("code", "math", blockMath, {
alt: ["paragraph", "reference", "blockquote", "list"], alt: ["paragraph", "reference", "blockquote", "list"],
}); });
}
}); });
} }