DEV: apply coding standards (#20)
This commit is contained in:
parent
926fbdbb3d
commit
e3068bb476
|
@ -1 +1,4 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
yarn-error.log
|
||||||
|
.rubocop-https---raw-githubusercontent-com-discourse-*
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = {
|
||||||
|
plugins: ["ember-template-lint-plugin-discourse"],
|
||||||
|
extends: "discourse:recommended",
|
||||||
|
};
|
|
@ -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");
|
||||||
});
|
});
|
||||||
|
@ -45,7 +45,7 @@ function katex($elem) {
|
||||||
|
|
||||||
function initializeMath(api) {
|
function initializeMath(api) {
|
||||||
api.decorateCooked(
|
api.decorateCooked(
|
||||||
function(elem) {
|
function (elem) {
|
||||||
katex(elem);
|
katex(elem);
|
||||||
},
|
},
|
||||||
{ id: "katex" }
|
{ id: "katex" }
|
||||||
|
@ -60,9 +60,9 @@ export default {
|
||||||
siteSettings.discourse_math_enabled &&
|
siteSettings.discourse_math_enabled &&
|
||||||
siteSettings.discourse_math_provider === "katex"
|
siteSettings.discourse_math_provider === "katex"
|
||||||
) {
|
) {
|
||||||
withPluginApi("0.5", function(api) {
|
withPluginApi("0.5", function (api) {
|
||||||
initializeMath(api);
|
initializeMath(api);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -118,7 +118,7 @@ function mathjax($elem, opts) {
|
||||||
|
|
||||||
function initializeMath(api, discourse_math_opts) {
|
function initializeMath(api, discourse_math_opts) {
|
||||||
api.decorateCooked(
|
api.decorateCooked(
|
||||||
function(elem) {
|
function (elem) {
|
||||||
mathjax(elem, discourse_math_opts);
|
mathjax(elem, discourse_math_opts);
|
||||||
},
|
},
|
||||||
{ id: "mathjax" }
|
{ id: "mathjax" }
|
||||||
|
@ -132,15 +132,15 @@ 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 &&
|
||||||
siteSettings.discourse_math_provider === "mathjax"
|
siteSettings.discourse_math_provider === "mathjax"
|
||||||
) {
|
) {
|
||||||
withPluginApi("0.5", function(api) {
|
withPluginApi("0.5", function (api) {
|
||||||
initializeMath(api, discourse_math_opts);
|
initializeMath(api, discourse_math_opts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"author": "Discourse",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint-config-discourse": "latest"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue