Skip to content

Commit 0855026

Browse files
committed
Release v2.0.0
- transfer to the Webpack bundler solution - fix of all error detected as a consequence of the transfer - minor problem : LaTeX menu symbol can no longer be rendered
1 parent 1d68446 commit 0855026

18 files changed

Lines changed: 1141 additions & 65 deletions

File tree

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,18 @@ The custom equations dialog with categories tree
9292

9393
## Known Problems
9494

95-
- Sometimes a start of the dialog crashes. Mainly I could observe this for first time starts of the production version. Perhaps this has to do with caching of the plugin. Restart helps.
96-
- [Here](./KNOWN-PROBLEMS.md) you can find further explanation.
9795
- A minor problem is a missing update of the language of the data grid paging bar in the *Custom Equations* dialog. This only appears during language change during an actual activation of the dialog.
9896
- The persistence of custom equations can be damaged when an filter is active.
9997

10098
## Release Notes
10199

100+
### 2.0.0
101+
102+
- Fixed the start problem, e.g. the known problems [document](./KNOWN-PROBLEMS.md) is no longer valid.
103+
- The functionality is more or less the same.
104+
- Fixed all problems detected during the adjustment to usage of Webpack as a bundler.
105+
- After the adjustment I had no single start failure.
106+
102107
### 1.0.10
103108

104109
- Fixed a lot of warnings in HTML.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "joplin-plugin-katex-input-helper",
3-
"version": "1.0.10",
3+
"version": "2.0.0",
44
"scripts": {
5-
"dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && npm run build-assets && webpack --env joplin-plugin-config=createArchive",
5+
"dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && npm run build-assets && npm run build-docs && webpack --env joplin-plugin-config=createArchive",
66
"prepare": "npm run dist",
77
"updateVersion": "webpack --env joplin-plugin-config=updateVersion",
88
"update": "npm install -g generator-joplin && yo joplin --node-package-manager npm --update --force",
99
"build-docs": "typedoc --options typedoc.json && npm exec --package=@atao60/fse-cli fse copy ./img ./docs/img",
1010
"test": "vitest --root './tests' --run --reporter verbose",
1111
"jtest": "jest",
1212
"build-assets": "webpack --config webpack.assets.config.js --mode development",
13-
"serve": "webpack serve --config webpack.assets.config.js"
13+
"serve": "webpack serve --config webpack.assets.config.js",
14+
"stop-serve": "npx kill-port 9000"
1415
},
1516
"license": "MIT",
1617
"keywords": [

src/assets/dialog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ <h3>Katex Input Helper</h3>
253253
id="f_SQRT_FRAC_SYMBOLS"></div>
254254
<div title="<span information='DIFFERENTIAL_SYMBOLS' class='rtl-title-withicon'>$\partial$ &nbsp;&nbsp; $\nabla a$ &nbsp;&nbsp; $dx$ </span>"
255255
id="f_DIFFERENTIAL_SYMBOLS"></div>
256-
<div title="<span information='INTEGRAL_SYMBOLS' class='rtl-title-withicon' style='font-size:60%;'>$\int$ &nbsp;&nbsp; $\oint$</span>"
256+
<div title="<span information='INTEGRAL_SYMBOLS' class='rtl-title-withicon' style='font-size:90%;'>$\int$ &nbsp;&nbsp; $\oint$</span>"
257257
id="f_INTEGRAL_SYMBOLS"></div>
258258
<div title="<span information='SUM_PROD_SYMBOLS' class='rtl-title-withicon' style='font-size:70%;'>$\sum$ &nbsp;&nbsp; $\prod$ </span>"
259259
id="f_SUM_PROD_SYMBOLS"></div>

src/assets/dialog2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ <h3>Katex Input Helper</h3>
255255
id="f_SQRT_FRAC_SYMBOLS"></div>
256256
<div title="<span information='DIFFERENTIAL_SYMBOLS' class='rtl-title-withicon'>$\partial$ &nbsp;&nbsp; $\nabla a$ &nbsp;&nbsp; $dx$ </span>"
257257
id="f_DIFFERENTIAL_SYMBOLS"></div>
258-
<div title="<span information='INTEGRAL_SYMBOLS' class='rtl-title-withicon' style='font-size:60%;'>$\int$ &nbsp;&nbsp; $\oint$</span>"
258+
<div title="<span information='INTEGRAL_SYMBOLS' class='rtl-title-withicon' style='font-size:90%;'>$\int$ &nbsp;&nbsp; $\oint$</span>"
259259
id="f_INTEGRAL_SYMBOLS"></div>
260260
<div title="<span information='SUM_PROD_SYMBOLS' class='rtl-title-withicon' style='font-size:70%;'>$\sum$ &nbsp;&nbsp; $\prod$ </span>"
261261
id="f_SUM_PROD_SYMBOLS"></div>

src/assets/js/codemirror/mode/meta.js

Lines changed: 221 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 264 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,264 @@
1-
CodeMirror.defineMode("stex",function(){function h(k,l){k.cmdState.push(l)}function g(k){if(k.cmdState.length>0){return k.cmdState[k.cmdState.length-1]}else{return null}}function j(l){if(l.cmdState.length>0){var k=l.cmdState.pop();k.closeBracket()}}function a(n){var m=n.cmdState;for(var l=m.length-1;l>=0;l--){var k=m[l];if(k.name=="DEFAULT"){continue}return k.styleIdentifier()}return null}function b(m,l,n,k){return function(){this.name=m;this.bracketNo=0;this.style=l;this.styles=k;this.brackets=n;this.styleIdentifier=function(){if(this.bracketNo<=this.styles.length){return this.styles[this.bracketNo-1]}else{return null}};this.openBracket=function(){this.bracketNo++;return"bracket"};this.closeBracket=function(){}}}var c=new Array();c.importmodule=b("importmodule","tag","{[",["string","builtin"]);c.documentclass=b("documentclass","tag","{[",["","atom"]);c.usepackage=b("documentclass","tag","[",["atom"]);c.begin=b("documentclass","tag","[",["atom"]);c.end=b("documentclass","tag","[",["atom"]);c.DEFAULT=function(){this.name="DEFAULT";this.style="tag";this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function d(l,k){l.f=k}function e(o,n){if(o.match(/^\\[a-zA-Z@]+/)){var l=o.current();l=l.substr(1,l.length-1);var k;if(c.hasOwnProperty(l)){k=c[l]}else{k=c.DEFAULT}k=new k();h(n,k);d(n,f);return k.style}if(o.match(/^\\[$&%#{}_]/)){return"tag"}if(o.match(/^\\[,;!\/]/)){return"tag"}var m=o.next();if(m=="%"){if(!o.eol()){d(n,i)}return"comment"}else{if(m=="}"||m=="]"){k=g(n);if(k){k.closeBracket(m);d(n,f)}else{return"error"}return"bracket"}else{if(m=="{"||m=="["){k=c.DEFAULT;k=new k();h(n,k);return"bracket"}else{if(/\d/.test(m)){o.eatWhile(/[\w.%]/);return"atom"}else{o.eatWhile(/[\w-_]/);return a(n)}}}}}function i(l,k){l.skipToEnd();d(k,e);return"comment"}function f(n,m){var l=n.peek();if(l=="{"||l=="["){var k=g(m);k.openBracket(l);n.eat(l);d(m,e);return"bracket"}if(/[ \t\r]/.test(l)){n.eat(l);return null}d(m,e);k=g(m);if(k){j(m)}return e(n,m)}return{startState:function(){return{f:e,cmdState:[]}},copyState:function(k){return{f:k.f,cmdState:k.cmdState.slice(0,k.cmdState.length)}},token:function(m,l){var k=l.f(m,l);return k}}});CodeMirror.defineMIME("text/x-stex","stex");CodeMirror.defineMIME("text/x-latex","stex");
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
3+
4+
/*
5+
* Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de)
6+
* Licence: MIT
7+
*/
8+
9+
(function(mod) {
10+
if (typeof exports == "object" && typeof module == "object") // CommonJS
11+
mod(require("../../lib/codemirror"));
12+
else if (typeof define == "function" && define.amd) // AMD
13+
define(["../../lib/codemirror"], mod);
14+
else // Plain browser env
15+
mod(CodeMirror);
16+
})(function(CodeMirror) {
17+
"use strict";
18+
19+
CodeMirror.defineMode("stex", function(_config, parserConfig) {
20+
"use strict";
21+
22+
function pushCommand(state, command) {
23+
state.cmdState.push(command);
24+
}
25+
26+
function peekCommand(state) {
27+
if (state.cmdState.length > 0) {
28+
return state.cmdState[state.cmdState.length - 1];
29+
} else {
30+
return null;
31+
}
32+
}
33+
34+
function popCommand(state) {
35+
var plug = state.cmdState.pop();
36+
if (plug) {
37+
plug.closeBracket();
38+
}
39+
}
40+
41+
// returns the non-default plugin closest to the end of the list
42+
function getMostPowerful(state) {
43+
var context = state.cmdState;
44+
for (var i = context.length - 1; i >= 0; i--) {
45+
var plug = context[i];
46+
if (plug.name == "DEFAULT") {
47+
continue;
48+
}
49+
return plug;
50+
}
51+
return { styleIdentifier: function() { return null; } };
52+
}
53+
54+
function addPluginPattern(pluginName, cmdStyle, styles) {
55+
return function () {
56+
this.name = pluginName;
57+
this.bracketNo = 0;
58+
this.style = cmdStyle;
59+
this.styles = styles;
60+
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
61+
62+
this.styleIdentifier = function() {
63+
return this.styles[this.bracketNo - 1] || null;
64+
};
65+
this.openBracket = function() {
66+
this.bracketNo++;
67+
return "bracket";
68+
};
69+
this.closeBracket = function() {};
70+
};
71+
}
72+
73+
var plugins = {};
74+
75+
plugins["importmodule"] = addPluginPattern("importmodule", "tag", ["string", "builtin"]);
76+
plugins["documentclass"] = addPluginPattern("documentclass", "tag", ["", "atom"]);
77+
plugins["usepackage"] = addPluginPattern("usepackage", "tag", ["atom"]);
78+
plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]);
79+
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
80+
81+
plugins["label" ] = addPluginPattern("label" , "tag", ["atom"]);
82+
plugins["ref" ] = addPluginPattern("ref" , "tag", ["atom"]);
83+
plugins["eqref" ] = addPluginPattern("eqref" , "tag", ["atom"]);
84+
plugins["cite" ] = addPluginPattern("cite" , "tag", ["atom"]);
85+
plugins["bibitem" ] = addPluginPattern("bibitem" , "tag", ["atom"]);
86+
plugins["Bibitem" ] = addPluginPattern("Bibitem" , "tag", ["atom"]);
87+
plugins["RBibitem" ] = addPluginPattern("RBibitem" , "tag", ["atom"]);
88+
89+
plugins["DEFAULT"] = function () {
90+
this.name = "DEFAULT";
91+
this.style = "tag";
92+
93+
this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
94+
};
95+
96+
function setState(state, f) {
97+
state.f = f;
98+
}
99+
100+
// called when in a normal (no environment) context
101+
function normal(source, state) {
102+
var plug;
103+
// Do we look like '\command' ? If so, attempt to apply the plugin 'command'
104+
if (source.match(/^\\[a-zA-Z@]+/)) {
105+
var cmdName = source.current().slice(1);
106+
plug = plugins.hasOwnProperty(cmdName) ? plugins[cmdName] : plugins["DEFAULT"];
107+
plug = new plug();
108+
pushCommand(state, plug);
109+
setState(state, beginParams);
110+
return plug.style;
111+
}
112+
113+
// escape characters
114+
if (source.match(/^\\[$&%#{}_]/)) {
115+
return "tag";
116+
}
117+
118+
// white space control characters
119+
if (source.match(/^\\[,;!\/\\]/)) {
120+
return "tag";
121+
}
122+
123+
// find if we're starting various math modes
124+
if (source.match("\\[")) {
125+
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
126+
return "keyword";
127+
}
128+
if (source.match("\\(")) {
129+
setState(state, function(source, state){ return inMathMode(source, state, "\\)"); });
130+
return "keyword";
131+
}
132+
if (source.match("$$")) {
133+
setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
134+
return "keyword";
135+
}
136+
if (source.match("$")) {
137+
setState(state, function(source, state){ return inMathMode(source, state, "$"); });
138+
return "keyword";
139+
}
140+
141+
var ch = source.next();
142+
if (ch == "%") {
143+
source.skipToEnd();
144+
return "comment";
145+
} else if (ch == '}' || ch == ']') {
146+
plug = peekCommand(state);
147+
if (plug) {
148+
plug.closeBracket(ch);
149+
setState(state, beginParams);
150+
} else {
151+
return "error";
152+
}
153+
return "bracket";
154+
} else if (ch == '{' || ch == '[') {
155+
plug = plugins["DEFAULT"];
156+
plug = new plug();
157+
pushCommand(state, plug);
158+
return "bracket";
159+
} else if (/\d/.test(ch)) {
160+
source.eatWhile(/[\w.%]/);
161+
return "atom";
162+
} else {
163+
source.eatWhile(/[\w\-_]/);
164+
plug = getMostPowerful(state);
165+
if (plug.name == 'begin') {
166+
plug.argument = source.current();
167+
}
168+
return plug.styleIdentifier();
169+
}
170+
}
171+
172+
function inMathMode(source, state, endModeSeq) {
173+
if (source.eatSpace()) {
174+
return null;
175+
}
176+
if (endModeSeq && source.match(endModeSeq)) {
177+
setState(state, normal);
178+
return "keyword";
179+
}
180+
if (source.match(/^\\[a-zA-Z@]+/)) {
181+
return "tag";
182+
}
183+
if (source.match(/^[a-zA-Z]+/)) {
184+
return "variable-2";
185+
}
186+
// escape characters
187+
if (source.match(/^\\[$&%#{}_]/)) {
188+
return "tag";
189+
}
190+
// white space control characters
191+
if (source.match(/^\\[,;!\/]/)) {
192+
return "tag";
193+
}
194+
// special math-mode characters
195+
if (source.match(/^[\^_&]/)) {
196+
return "tag";
197+
}
198+
// non-special characters
199+
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
200+
return null;
201+
}
202+
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
203+
return "number";
204+
}
205+
var ch = source.next();
206+
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
207+
return "bracket";
208+
}
209+
210+
if (ch == "%") {
211+
source.skipToEnd();
212+
return "comment";
213+
}
214+
return "error";
215+
}
216+
217+
function beginParams(source, state) {
218+
var ch = source.peek(), lastPlug;
219+
if (ch == '{' || ch == '[') {
220+
lastPlug = peekCommand(state);
221+
lastPlug.openBracket(ch);
222+
source.eat(ch);
223+
setState(state, normal);
224+
return "bracket";
225+
}
226+
if (/[ \t\r]/.test(ch)) {
227+
source.eat(ch);
228+
return null;
229+
}
230+
setState(state, normal);
231+
popCommand(state);
232+
233+
return normal(source, state);
234+
}
235+
236+
return {
237+
startState: function() {
238+
var f = parserConfig.inMathMode ? function(source, state){ return inMathMode(source, state); } : normal;
239+
return {
240+
cmdState: [],
241+
f: f
242+
};
243+
},
244+
copyState: function(s) {
245+
return {
246+
cmdState: s.cmdState.slice(),
247+
f: s.f
248+
};
249+
},
250+
token: function(stream, state) {
251+
return state.f(stream, state);
252+
},
253+
blankLine: function(state) {
254+
state.f = normal;
255+
state.cmdState.length = 0;
256+
},
257+
lineComment: "%"
258+
};
259+
});
260+
261+
CodeMirror.defineMIME("text/x-stex", "stex");
262+
CodeMirror.defineMIME("text/x-latex", "stex");
263+
264+
});

0 commit comments

Comments
 (0)