DEV: apply coding standards (#20)

This commit is contained in:
Joffrey JAFFEUX 2020-09-04 13:22:43 +02:00 committed by GitHub
parent 926fbdbb3d
commit e3068bb476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1623 additions and 11 deletions

3
.eslintrc Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "eslint-config-discourse"
}

3
.gitignore vendored
View File

@ -1 +1,4 @@
.DS_Store .DS_Store
node_modules
yarn-error.log
.rubocop-https---raw-githubusercontent-com-discourse-*

4
.template-lintrc.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended",
};

View File

@ -4,7 +4,7 @@ import loadScript from "discourse/lib/load-script";
function ensureKaTeX() { function ensureKaTeX() {
return loadScript("/plugins/discourse-math/katex/katex.min.js").then(() => { return loadScript("/plugins/discourse-math/katex/katex.min.js").then(() => {
return loadScript("/plugins/discourse-math/katex/katex.min.css", { return loadScript("/plugins/discourse-math/katex/katex.min.css", {
css: true css: true,
}).then(() => { }).then(() => {
return loadScript("/plugins/discourse-math/katex/mhchem.min.js"); return loadScript("/plugins/discourse-math/katex/mhchem.min.js");
}); });
@ -64,5 +64,5 @@ export default {
initializeMath(api); initializeMath(api);
}); });
} }
} },
}; };

View File

@ -20,7 +20,7 @@ function initMathJax(opts) {
TeX: { extensions: ["AMSmath.js", "AMSsymbols.js", "autoload-all.js"] }, TeX: { extensions: ["AMSmath.js", "AMSsymbols.js", "autoload-all.js"] },
extensions: extensions, extensions: extensions,
showProcessingMessages: false, showProcessingMessages: false,
root: getURLWithCDN("/plugins/discourse-math/mathjax") root: getURLWithCDN("/plugins/discourse-math/mathjax"),
}; };
if (opts.zoom_on_hover) { if (opts.zoom_on_hover) {
@ -132,7 +132,7 @@ export default {
let discourse_math_opts = { let discourse_math_opts = {
zoom_on_hover: siteSettings.discourse_math_zoom_on_hover, zoom_on_hover: siteSettings.discourse_math_zoom_on_hover,
enable_accessibility: siteSettings.discourse_math_enable_accessibility, enable_accessibility: siteSettings.discourse_math_enable_accessibility,
enable_asciimath: siteSettings.discourse_math_enable_asciimath enable_asciimath: siteSettings.discourse_math_enable_asciimath,
}; };
if ( if (
siteSettings.discourse_math_enabled && siteSettings.discourse_math_enabled &&
@ -142,5 +142,5 @@ export default {
initializeMath(api, discourse_math_opts); initializeMath(api, discourse_math_opts);
}); });
} }
} },
}; };

View File

@ -170,13 +170,13 @@ export function setup(helper) {
enable_asciimath = siteSettings.discourse_math_enable_asciimath; enable_asciimath = siteSettings.discourse_math_enable_asciimath;
}); });
helper.registerPlugin(md => { helper.registerPlugin((md) => {
if (enable_asciimath) { if (enable_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"],
}); });
}); });
} }

7
package.json Normal file
View File

@ -0,0 +1,7 @@
{
"author": "Discourse",
"license": "MIT",
"devDependencies": {
"eslint-config-discourse": "latest"
}
}

1595
yarn.lock Normal file

File diff suppressed because it is too large Load Diff