diff --git a/.editorconfig b/.editorconfig index a5e08f70..9cbe461c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,27 +1,39 @@ -# This will be used as default EditorConfig for repos that don't have their own. -# It's saved automatically as you type. -# You can find docs at http://editorconfig.org +[*] +charset=utf-8 +end_of_line=lf +insert_final_newline=false +indent_style=space +indent_size=4 -root = true +[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.json,*.jsb3,*.jsb2,*.bowerrc}] +indent_style=space +indent_size=2 -[*] +[{*.applejs,*.js}] +indent_style=space +indent_size=2 + +[*.js.flow] +indent_style=space +indent_size=2 + +[{jshint.json,*.jshintrc}] +indent_style=space +indent_size=2 -# Change these settings to your own preference -indent_style = space -indent_size = 4 +[{*.jscs.json,*.jscsrc}] +indent_style=space +indent_size=2 -# We recommend you to keep these unchanged -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true +[*.scss] +indent_style=space +indent_size=2 -[*.md] -trim_trailing_whitespace = false +[*.coffee] +indent_style=space +indent_size=2 -[{package,bower}.json] -indent_style = space -indent_size = 2 +[{.analysis_options,*.yml,*.yaml}] +indent_style=space +indent_size=2 -[Makefile] -indent_style = tab diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..5e6ea3a1 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,25 @@ +{ + "extends": "airbnb", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "rules": { + "semi": 2, + "no-unused-vars" : "off", + "no-plusplus" : "off", + "no-restricted-properties" : "off", + "prefer-template" : "off", + "import/no-extraneous-dependencies" : "off", + "import/prefer-default-export" : "off", + "max-len": ["off", 100, 2, { + "ignoreUrls": true, + "ignoreComments": false, + "ignoreStrings": true, + "ignoreTemplateLiterals": true + }] + } +} diff --git a/bower.json b/bower.json index 124ba5a7..35c59a03 100644 --- a/bower.json +++ b/bower.json @@ -30,11 +30,11 @@ "!demo/**/*" ], "dependencies": { - "polymer": "Polymer/polymer#1.9.x", + "polymer": "Polymer/polymer#^2.0.1", "myscript-common-element": "2.0.0-alpha1", - "KaTeX": "katex#0.7.x" + "KaTeX": "katex#^0.7.1" }, "devDependencies": { - "iron-component-page": "PolymerElements/iron-component-page#1.1.x" + "iron-component-page": "PolymerElements/iron-component-page#^3.0.0" } } diff --git a/katex-component.html b/katex-component.html index 01b958bf..19a3f95c 100644 --- a/katex-component.html +++ b/katex-component.html @@ -1,42 +1,1054 @@ - + - - - - + + } + customElements.define(KatexComponent.is, KatexComponent); + + diff --git a/myscript-math-exports.html b/myscript-math-exports.html index 54787cde..0637cf78 100644 --- a/myscript-math-exports.html +++ b/myscript-math-exports.html @@ -1,24 +1,26 @@ - + - - + + + _getLatex(exports) { + if (exports['application/x-latex']) { + return exports['application/x-latex'] || ''; + } + return exports.LATEX || ''; + } + + _getLatexCleaned(exports) { + return this._getLatex(exports) + .replace("\\overrightarrow", "\\vec") + .replace("\\llbracket", "\\lbracket") + .replace("\\rrbracket", "\\rbracket") + .replace("\\widehat", "\\hat") + .replace(new RegExp("(align.{1})", "g"), "aligned"); + } + + _getMathml(exports) { + if (exports['application/mathml+xml']) { + return exports['application/mathml+xml']; + } + return exports.MATHML; + } + + _getOfficeopenxml(exports) { + if (exports['application/mathofficeXML']) { + return exports['application/mathofficeXML']; + } + return exports.OFFICEOPENXMLMATH; + } + + _getSymboltree(exports) { + return JSON.stringify(exports.SYMBOLTREE); + } + + _displaymath(resulttypes, mimetypes) { + return !((resulttypes.length > 0) || (mimetypes.length > 0)); + } + + _displaylatex(resulttypes, mimetypes) { + return (resulttypes.indexOf('LATEX') > -1) || (mimetypes.indexOf('application/x-latex') > -1); + } + + _displaymathml(resulttypes, mimetypes) { + return (resulttypes.indexOf('MATHML') > -1) || (mimetypes.indexOf('application/mathml+xml') > -1); + } + + _displayofficeopenxml(resulttypes, mimetypes) { + return (resulttypes.indexOf('OFFICEOPENXMLMATH') > -1) || (mimetypes.indexOf('application/mathofficeXML') > -1); + } + + _displaysymboltree(resulttypes, mimetypes) { + return resulttypes.indexOf('SYMBOLTREE') > -1; + } + + } + customElements.define(MyScriptMathExports.is, MyScriptMathExports); + + + diff --git a/myscript-math-web.html b/myscript-math-web.html index 8d6f559c..22e180a0 100644 --- a/myscript-math-web.html +++ b/myscript-math-web.html @@ -1,4 +1,4 @@ - + -