Tchanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252891

Change subject: WIP Add tool to create svg files of LaTeX symbols
......................................................................

WIP Add tool to create svg files of LaTeX symbols

Also produces a css file for the symbol buttons, using the
svg filenames. Gets the list of symbols from symbols.json.

Change-Id: Iaa792418d870a7e266b6455ef037994e31278278
---
M extension.json
A modules/ve-math/symbols.json
A modules/ve-math/tools/makeSvgsAndCss.js
A modules/ve-math/tools/package.json
4 files changed, 1,320 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/91/252891/1

diff --git a/extension.json b/extension.json
index 83dcddf..07c074f 100644
--- a/extension.json
+++ b/extension.json
@@ -144,7 +144,7 @@
                        "styles": [
                                "ve-math/ve.ce.MWMathNode.css",
                                "ve-math/ve.ui.MWMathIcons.css",
-                               "ve-math/ve.ui.MWMathInspector.css"
+                               "ve-math/ve.ui.MWMathSymbols.css"
                        ],
                        "dependencies": [
                                "ext.visualEditor.mwcore"
diff --git a/modules/ve-math/symbols.json b/modules/ve-math/symbols.json
new file mode 100644
index 0000000..fab6b7e
--- /dev/null
+++ b/modules/ve-math/symbols.json
@@ -0,0 +1,1195 @@
+{
+       "Derivatives": [
+               {
+                       "tex": "\\nabla"
+               },
+               {
+                       "tex": "\\partial"
+               }
+       ],
+       "Accents/diacritics": [
+               {
+                       "tex": "\\acute{a}"
+               },
+               {
+                       "tex": "\\grave{a}"
+               },
+               {
+                       "tex": "\\hat{a}"
+               },
+               {
+                       "tex": "\\tilde{a}"
+               },
+               {
+                       "tex": "\\breve{a}"
+               },
+               {
+                       "tex": "\\check{a}"
+               },
+               {
+                       "tex": "\\bar{a}"
+               },
+               {
+                       "tex": "\\ddot{a}"
+               },
+               {
+                       "tex": "\\dot{a}"
+               }
+       ],
+       "Modular arithmetic": [
+               {
+                       "tex": "\\pmod{a}"
+               },
+               {
+                       "tex": "\\bmod{a}"
+               }
+       ],
+       "Operators": [
+               {
+                       "tex": "+"
+               },
+               {
+                       "tex": "\\oplus"
+               },
+               {
+                       "tex": "\\bigoplus"
+               },
+               {
+                       "tex": "\\pm"
+               },
+               {
+                       "tex": "\\mp"
+               },
+               {
+                       "tex": "-"
+               },
+               {
+                       "tex": "\\times"
+               },
+               {
+                       "tex": "\\otimes"
+               },
+               {
+                       "tex": "\\bigotimes"
+               },
+               {
+                       "tex": "\\cdot"
+               },
+               {
+                       "tex": "\\circ"
+               },
+               {
+                       "tex": "\\bullet"
+               },
+               {
+                       "tex": "\\bigodot"
+               },
+               {
+                       "tex": "\\star"
+               },
+               {
+                       "tex": "*"
+               },
+               {
+                       "tex": "/"
+               },
+               {
+                       "tex": "\\div"
+               }
+       ],
+       "Logic": [
+               {
+                       "tex": "\\land"
+               },
+               {
+                       "tex": "\\wedge"
+               },
+               {
+                       "tex": "\\bigwedge"
+               },
+               {
+                       "tex": "\\lor"
+               },
+               {
+                       "tex": "\\vee"
+               },
+               {
+                       "tex": "\\bigvee"
+               },
+               {
+                       "tex": "\\lnot"
+               },
+               {
+                       "tex": "\\neg"
+               },
+               {
+                       "tex": "\\And"
+               }
+       ],
+       "Arrows": [
+               {
+                       "tex": "\\Leftarrow"
+               },
+               {
+                       "tex": "\\Rightarrow"
+               },
+               {
+                       "tex": "\\nleftarrow"
+               },
+               {
+                       "tex": "\\nrightarrow"
+               },
+               {
+                       "tex": "\\leftrightarrow"
+               },
+               {
+                       "tex": "\\nleftrightarrow"
+               },
+               {
+                       "tex": "\\longleftarrow"
+               },
+               {
+                       "tex": "\\nLeftarrow"
+               },
+               {
+                       "tex": "\\nRightarrow"
+               },
+               {
+                       "tex": "\\Leftrightarrow"
+               },
+               {
+                       "tex": "\\nLeftrightarrow"
+               },
+               {
+                       "tex": "\\Longleftarrow"
+               },
+               {
+                       "tex": "\\longrightarrow"
+               },
+               {
+                       "tex": "\\longleftrightarrow"
+               },
+               {
+                       "tex": "\\uparrow"
+               },
+               {
+                       "tex": "\\downarrow"
+               },
+               {
+                       "tex": "\\updownarrow"
+               },
+               {
+                       "tex": "\\Uparrow"
+               },
+               {
+                       "tex": "\\Downarrow"
+               },
+               {
+                       "tex": "\\Updownarrow"
+               },
+               {
+                       "tex": "\\nearrow"
+               },
+               {
+                       "tex": "\\searrow"
+               },
+               {
+                       "tex": "\\swarrow"
+               },
+               {
+                       "tex": "\\nwarrow"
+               },
+               {
+                       "tex": "\\rightharpoonup"
+               },
+               {
+                       "tex": "\\rightharpoondown"
+               },
+               {
+                       "tex": "\\leftharpoonup"
+               },
+               {
+                       "tex": "\\leftharpoondown"
+               },
+               {
+                       "tex": "\\upharpoonleft"
+               },
+               {
+                       "tex": "\\upharpoonright"
+               },
+               {
+                       "tex": "\\downharpoonleft"
+               },
+               {
+                       "tex": "\\downharpoonright"
+               },
+               {
+                       "tex": "\\rightleftharpoons"
+               },
+               {
+                       "tex": "\\leftrightharpoons"
+               },
+               {
+                       "tex": "\\curvearrowright"
+               },
+               {
+                       "tex": "\\circlearrowright"
+               },
+               {
+                       "tex": "\\Rsh"
+               },
+               {
+                       "tex": "\\downdownarrows"
+               },
+               {
+                       "tex": "\\leftleftarrows"
+               },
+               {
+                       "tex": "\\leftrightarrows"
+               },
+               {
+                       "tex": "\\Lleftarrow"
+               },
+               {
+                       "tex": "\\leftarrowtail"
+               },
+               {
+                       "tex": "\\looparrowleft"
+               },
+               {
+                       "tex": "\\mapsto"
+               },
+               {
+                       "tex": "\\longmapsto"
+               },
+               {
+                       "tex": "\\hookrightarrow"
+               },
+               {
+                       "tex": "\\hookleftarrow"
+               },
+               {
+                       "tex": "\\multimap"
+               },
+               {
+                       "tex": "\\leftrightsquigarrow"
+               },
+               {
+                       "tex": "\\rightsquigarrow"
+               }
+       ],
+       "Standard functions": [
+               {
+                       "tex": "\\sin"
+               },
+               {
+                       "tex": "\\cos"
+               },
+               {
+                       "tex": "\\tan"
+               },
+               {
+                       "tex": "\\sec"
+               },
+               {
+                       "tex": "\\csc"
+               },
+               {
+                       "tex": "\\cot"
+               },
+               {
+                       "tex": "\\arcsin"
+               },
+               {
+                       "tex": "\\arccos"
+               },
+               {
+                       "tex": "\\arctan"
+               },
+               {
+                       "tex": "\\sinh"
+               },
+               {
+                       "tex": "\\cosh"
+               },
+               {
+                       "tex": "\\tanh"
+               },
+               {
+                       "tex": "\\coth"
+               },
+               {
+                       "tex": "\\operatorname{sh}"
+               },
+               {
+                       "tex": "\\operatorname{ch}"
+               },
+               {
+                       "tex": "\\operatorname{th}"
+               },
+               {
+                       "tex": "\\operatorname{arsinh}"
+               },
+               {
+                       "tex": "\\operatorname{arcosh}"
+               },
+               {
+                       "tex": "\\operatorname{artanh}"
+               },
+               {
+                       "tex": "\\lim"
+               },
+               {
+                       "tex": "\\limsup"
+               },
+               {
+                       "tex": "\\liminf"
+               },
+               {
+                       "tex": "\\min"
+               },
+               {
+                       "tex": "\\max"
+               },
+               {
+                       "tex": "\\inf"
+               },
+               {
+                       "tex": "\\sup"
+               },
+               {
+                       "tex": "\\exp"
+               },
+               {
+                       "tex": "\\ln"
+               },
+               {
+                       "tex": "\\lg"
+               },
+               {
+                       "tex": "\\log"
+               },
+               {
+                       "tex": "\\log_{a}"
+               },
+               {
+                       "tex": "\\ker"
+               },
+               {
+                       "tex": "\\deg"
+               },
+               {
+                       "tex": "\\gcd"
+               },
+               {
+                       "tex": "\\Pr"
+               },
+               {
+                       "tex": "\\det"
+               },
+               {
+                       "tex": "\\hom"
+               },
+               {
+                       "tex": "\\arg"
+               },
+               {
+                       "tex": "\\dim"
+               }
+       ],
+       "Unsorted (new stuff)": [
+               {
+                       "tex": "\\vartriangle"
+               },
+               {
+                       "tex": "\\triangledown"
+               },
+               {
+                       "tex": "\\lozenge"
+               },
+               {
+                       "tex": "\\circledS"
+               },
+               {
+                       "tex": "\\measuredangle"
+               },
+               {
+                       "tex": "\\nexists"
+               },
+               {
+                       "tex": "\\Bbbk"
+               },
+               {
+                       "tex": "\\backprime"
+               },
+               {
+                       "tex": "\\blacktriangle"
+               },
+               {
+                       "tex": "\\blacktriangledown"
+               },
+               {
+                       "tex": "\\square"
+               },
+               {
+                       "tex": "\\blacksquare"
+               },
+               {
+                       "tex": "\\blacklozenge"
+               },
+               {
+                       "tex": "\\bigstar"
+               },
+               {
+                       "tex": "\\sphericalangle"
+               },
+               {
+                       "tex": "\\diagup"
+               },
+               {
+                       "tex": "\\diagdown"
+               },
+               {
+                       "tex": "\\dotplus"
+               },
+               {
+                       "tex": "\\Cap"
+               },
+               {
+                       "tex": "\\Cup"
+               },
+               {
+                       "tex": "\\barwedge"
+               },
+               {
+                       "tex": "\\veebar"
+               },
+               {
+                       "tex": "\\doublebarwedge"
+               },
+               {
+                       "tex": "\\boxminus"
+               },
+               {
+                       "tex": "\\boxtimes"
+               },
+               {
+                       "tex": "\\boxdot"
+               },
+               {
+                       "tex": "\\boxplus"
+               },
+               {
+                       "tex": "\\divideontimes"
+               },
+               {
+                       "tex": "\\ltimes"
+               },
+               {
+                       "tex": "\\rtimes"
+               },
+               {
+                       "tex": "\\leftthreetimes"
+               },
+               {
+                       "tex": "\\rightthreetimes"
+               },
+               {
+                       "tex": "\\curlywedge"
+               },
+               {
+                       "tex": "\\curlyvee"
+               },
+               {
+                       "tex": "\\circleddash"
+               },
+               {
+                       "tex": "\\circledast"
+               },
+               {
+                       "tex": "\\circledcirc"
+               },
+               {
+                       "tex": "\\centerdot"
+               },
+               {
+                       "tex": "\\intercal"
+               },
+               {
+                       "tex": "\\approxeq"
+               },
+               {
+                       "tex": "\\lessdot"
+               },
+               {
+                       "tex": "\\lll"
+               },
+               {
+                       "tex": "\\lessgtr"
+               },
+               {
+                       "tex": "\\lesseqgtr"
+               },
+               {
+                       "tex": "\\lesseqqgtr"
+               },
+               {
+                       "tex": "\\doteqdot"
+               },
+               {
+                       "tex": "\\risingdotseq"
+               },
+               {
+                       "tex": "\\fallingdotseq"
+               },
+               {
+                       "tex": "\\backsim"
+               },
+               {
+                       "tex": "\\backsimeq"
+               },
+               {
+                       "tex": "\\subseteqq"
+               },
+               {
+                       "tex": "\\Subset"
+               },
+               {
+                       "tex": "\\preccurlyeq"
+               },
+               {
+                       "tex": "\\curlyeqprec"
+               },
+               {
+                       "tex": "\\precsim"
+               },
+               {
+                       "tex": "\\precapprox"
+               },
+               {
+                       "tex": "\\vartriangleleft"
+               },
+               {
+                       "tex": "\\Vvdash"
+               },
+               {
+                       "tex": "\\bumpeq"
+               },
+               {
+                       "tex": "\\Bumpeq"
+               },
+               {
+                       "tex": "\\eqsim"
+               },
+               {
+                       "tex": "\\gtrdot"
+               },
+               {
+                       "tex": "\\ggg"
+               },
+               {
+                       "tex": "\\gtrless"
+               },
+               {
+                       "tex": "\\gtreqless"
+               },
+               {
+                       "tex": "\\gtreqqless"
+               },
+               {
+                       "tex": "\\eqcirc"
+               },
+               {
+                       "tex": "\\circeq"
+               },
+               {
+                       "tex": "\\triangleq"
+               },
+               {
+                       "tex": "\\thicksim"
+               },
+               {
+                       "tex": "\\thickapprox"
+               },
+               {
+                       "tex": "\\supseteqq"
+               },
+               {
+                       "tex": "\\Supset"
+               },
+               {
+                       "tex": "\\succcurlyeq"
+               },
+               {
+                       "tex": "\\curlyeqsucc"
+               },
+               {
+                       "tex": "\\succsim"
+               },
+               {
+                       "tex": "\\succapprox"
+               },
+               {
+                       "tex": "\\vartriangleright"
+               },
+               {
+                       "tex": "\\shortmid"
+               },
+               {
+                       "tex": "\\between"
+               },
+               {
+                       "tex": "\\shortparallel"
+               },
+               {
+                       "tex": "\\pitchfork"
+               },
+               {
+                       "tex": "\\varpropto"
+               },
+               {
+                       "tex": "\\blacktriangleleft"
+               },
+               {
+                       "tex": "\\therefore"
+               },
+               {
+                       "tex": "\\backepsilon"
+               },
+               {
+                       "tex": "\\blacktriangleright"
+               },
+               {
+                       "tex": "\\because"
+               },
+               {
+                       "tex": "\\nleqslant"
+               },
+               {
+                       "tex": "\\nleqq"
+               },
+               {
+                       "tex": "\\lneq"
+               },
+               {
+                       "tex": "\\lneqq"
+               },
+               {
+                       "tex": "\\lvertneqq"
+               },
+               {
+                       "tex": "\\lnsim"
+               },
+               {
+                       "tex": "\\lnapprox"
+               },
+               {
+                       "tex": "\\nprec"
+               },
+               {
+                       "tex": "\\npreceq"
+               },
+               {
+                       "tex": "\\precneqq"
+               },
+               {
+                       "tex": "\\precnsim"
+               },
+               {
+                       "tex": "\\precnapprox"
+               },
+               {
+                       "tex": "\\nsim"
+               },
+               {
+                       "tex": "\\nshortmid"
+               },
+               {
+                       "tex": "\\nvdash"
+               },
+               {
+                       "tex": "\\nVdash"
+               },
+               {
+                       "tex": "\\ntriangleleft"
+               },
+               {
+                       "tex": "\\ntrianglelefteq"
+               },
+               {
+                       "tex": "\\nsubseteq"
+               },
+               {
+                       "tex": "\\nsubseteqq"
+               },
+               {
+                       "tex": "\\varsubsetneq"
+               },
+               {
+                       "tex": "\\subsetneqq"
+               },
+               {
+                       "tex": "\\varsubsetneqq"
+               },
+               {
+                       "tex": "\\ngtr"
+               },
+               {
+                       "tex": "\\subsetneq"
+               },
+               {
+                       "tex": "\\ngeqslant"
+               },
+               {
+                       "tex": "\\ngeqq"
+               },
+               {
+                       "tex": "\\gneq"
+               },
+               {
+                       "tex": "\\gneqq"
+               },
+               {
+                       "tex": "\\gvertneqq"
+               },
+               {
+                       "tex": "\\gnsim"
+               },
+               {
+                       "tex": "\\gnapprox"
+               },
+               {
+                       "tex": "\\nsucc"
+               },
+               {
+                       "tex": "\\nsucceq"
+               },
+               {
+                       "tex": "\\succneqq"
+               },
+               {
+                       "tex": "\\succnsim"
+               },
+               {
+                       "tex": "\\succnapprox"
+               },
+               {
+                       "tex": "\\ncong"
+               },
+               {
+                       "tex": "\\nshortparallel"
+               },
+               {
+                       "tex": "\\nparallel"
+               },
+               {
+                       "tex": "\\nvDash"
+               },
+               {
+                       "tex": "\\nVDash"
+               },
+               {
+                       "tex": "\\ntriangleright"
+               },
+               {
+                       "tex": "\\ntrianglerighteq"
+               },
+               {
+                       "tex": "\\nsupseteq"
+               },
+               {
+                       "tex": "\\nsupseteqq"
+               },
+               {
+                       "tex": "\\varsupsetneq"
+               },
+               {
+                       "tex": "\\supsetneqq"
+               },
+               {
+                       "tex": "\\varsupsetneqq"
+               },
+               {
+                       "tex": "\\jmath"
+               },
+               {
+                       "tex": "\\surd"
+               },
+               {
+                       "tex": "\\ast"
+               },
+               {
+                       "tex": "\\uplus"
+               },
+               {
+                       "tex": "\\diamond"
+               },
+               {
+                       "tex": "\\bigtriangleup"
+               },
+               {
+                       "tex": "\\bigtriangledown"
+               },
+               {
+                       "tex": "\\ominus"
+               },
+               {
+                       "tex": "\\oslash"
+               },
+               {
+                       "tex": "\\odot"
+               },
+               {
+                       "tex": "\\bigcirc"
+               },
+               {
+                       "tex": "\\amalg"
+               },
+               {
+                       "tex": "\\prec"
+               },
+               {
+                       "tex": "\\succ"
+               },
+               {
+                       "tex": "\\preceq"
+               },
+               {
+                       "tex": "\\succeq"
+               },
+               {
+                       "tex": "\\dashv"
+               },
+               {
+                       "tex": "\\asymp"
+               },
+               {
+                       "tex": "\\doteq"
+               },
+               {
+                       "tex": "\\parallel"
+               },
+               {
+                       "tex": "\\ulcorner"
+               },
+               {
+                       "tex": "\\urcorner"
+               },
+               {
+                       "tex": "\\llcorner"
+               },
+               {
+                       "tex": "\\lrcorner"
+               }
+       ],
+       "Relations": [
+               {
+                       "tex": "\\sim"
+               },
+               {
+                       "tex": "\\approx"
+               },
+               {
+                       "tex": "\\simeq"
+               },
+               {
+                       "tex": "\\cong"
+               },
+               {
+                       "tex": "\\dot="
+               },
+               {
+                       "tex": "\\overset{\\underset{\\mathrm{def}}{}}{=}"
+               },
+               {
+                       "tex": "<"
+               },
+               {
+                       "tex": "\\le"
+               },
+               {
+                       "tex": "\\ll"
+               },
+               {
+                       "tex": "\\gg"
+               },
+               {
+                       "tex": "\\ge"
+               },
+               {
+                       "tex": ">"
+               },
+               {
+                       "tex": "\\equiv"
+               },
+               {
+                       "tex": "\\not\\equiv"
+               },
+               {
+                       "tex": "\\ne"
+               },
+               {
+                       "tex": "\\propto"
+               },
+               {
+                       "tex": "\\lessapprox"
+               },
+               {
+                       "tex": "\\lesssim"
+               },
+               {
+                       "tex": "\\eqslantless"
+               },
+               {
+                       "tex": "\\leqslant"
+               },
+               {
+                       "tex": "\\leqq"
+               },
+               {
+                       "tex": "\\geqq"
+               },
+               {
+                       "tex": "\\geqslant"
+               },
+               {
+                       "tex": "\\eqslantgtr"
+               },
+               {
+                       "tex": "\\gtrsim"
+               },
+               {
+                       "tex": "\\gtrapprox"
+               }
+       ],
+       "Sets": [
+               {
+                       "tex": "\\forall"
+               },
+               {
+                       "tex": "\\exists"
+               },
+               {
+                       "tex": "\\empty"
+               },
+               {
+                       "tex": "\\varnothing"
+               },
+               {
+                       "tex": "\\in"
+               },
+               {
+                       "tex": "\\ni"
+               },
+               {
+                       "tex": "\\notin"
+               },
+               {
+                       "tex": "\\subset"
+               },
+               {
+                       "tex": "\\subseteq"
+               },
+               {
+                       "tex": "\\supset"
+               },
+               {
+                       "tex": "\\supseteq"
+               },
+               {
+                       "tex": "\\cap"
+               },
+               {
+                       "tex": "\\bigcap"
+               },
+               {
+                       "tex": "\\cup"
+               },
+               {
+                       "tex": "\\bigcup"
+               },
+               {
+                       "tex": "\\biguplus"
+               },
+               {
+                       "tex": "\\setminus"
+               },
+               {
+                       "tex": "\\smallsetminus"
+               },
+               {
+                       "tex": "\\sqsubset"
+               },
+               {
+                       "tex": "\\sqsubseteq"
+               },
+               {
+                       "tex": "\\sqsupset"
+               },
+               {
+                       "tex": "\\sqsupseteq"
+               },
+               {
+                       "tex": "\\sqcap"
+               },
+               {
+                       "tex": "\\sqcup"
+               },
+               {
+                       "tex": "\\bigsqcup"
+               }
+       ],
+       "Geometric": [
+               {
+                       "tex": "\\Diamond"
+               },
+               {
+                       "tex": "\\Box"
+               },
+               {
+                       "tex": "\\triangle"
+               },
+               {
+                       "tex": "\\angle"
+               },
+               {
+                       "tex": "\\perp"
+               },
+               {
+                       "tex": "\\mid"
+               },
+               {
+                       "tex": "\\nmid"
+               },
+               {
+                       "tex": "\\|"
+               },
+               {
+                       "tex": "a^\\circ"
+               }
+       ],
+       "Root": [
+               {
+                       "tex": "\\sqrt{a}"
+               },
+               {
+                       "tex": "\\sqrt[b]{a}"
+               }
+       ],
+       "Special": [
+               {
+                       "tex": "\\eth"
+               },
+               {
+                       "tex": "\\S"
+               },
+               {
+                       "tex": "\\%"
+               },
+               {
+                       "tex": "\\dagger"
+               },
+               {
+                       "tex": "\\ddagger"
+               },
+               {
+                       "tex": "\\ldots"
+               },
+               {
+                       "tex": "\\cdots"
+               },
+               {
+                       "tex": "\\smile"
+               },
+               {
+                       "tex": "\\frown"
+               },
+               {
+                       "tex": "\\wr"
+               },
+               {
+                       "tex": "\\triangleleft"
+               },
+               {
+                       "tex": "\\triangleright"
+               },
+               {
+                       "tex": "\\infty"
+               },
+               {
+                       "tex": "\\bot"
+               },
+               {
+                       "tex": "\\top"
+               },
+               {
+                       "tex": "\\vdash"
+               },
+               {
+                       "tex": "\\vDash"
+               },
+               {
+                       "tex": "\\Vdash"
+               },
+               {
+                       "tex": "\\models"
+               },
+               {
+                       "tex": "\\lVert"
+               },
+               {
+                       "tex": "\\rVert"
+               },
+               {
+                       "tex": "\\imath"
+               },
+               {
+                       "tex": "\\hbar"
+               },
+               {
+                       "tex": "\\ell"
+               },
+               {
+                       "tex": "\\mho"
+               },
+               {
+                       "tex": "\\Finv"
+               },
+               {
+                       "tex": "\\Re"
+               },
+               {
+                       "tex": "\\Im"
+               },
+               {
+                       "tex": "\\wp"
+               },
+               {
+                       "tex": "\\complement"
+               },
+               {
+                       "tex": "\\diamondsuit"
+               },
+               {
+                       "tex": "\\heartsuit"
+               },
+               {
+                       "tex": "\\clubsuit"
+               },
+               {
+                       "tex": "\\spadesuit"
+               },
+               {
+                       "tex": "\\Game"
+               },
+               {
+                       "tex": "\\flat"
+               },
+               {
+                       "tex": "\\natural"
+               },
+               {
+                       "tex": "\\sharp"
+               }
+       ]
+}
\ No newline at end of file
diff --git a/modules/ve-math/tools/makeSvgsAndCss.js 
b/modules/ve-math/tools/makeSvgsAndCss.js
new file mode 100644
index 0000000..01dc1ac
--- /dev/null
+++ b/modules/ve-math/tools/makeSvgsAndCss.js
@@ -0,0 +1,117 @@
+#!/usr/bin/env node
+
+/* jshint node: true */
+
+var i, count, group, symbols, symbolObject,
+       symbolList = [],
+       dirname = '../symbols',
+       symbolsFile = '../symbols.json',
+       cssFile = '../ve.ui.MWMathSymbols.css',
+       fs = require( 'fs' ),
+       http = require( 'http' ),
+       querystring = require( 'querystring' ),
+       md5 = require( 'md5' ),
+       SVGO = require( 'svgo' ),
+       // svgo --pretty --disable=removeXMLProcInst --disable=cleanupIDs 
--disable=collapseGroups --disable=convertTransform
+       svgo = new SVGO( {
+               plugins: [
+                       { removeXMLProcInst: false },
+                       { cleanupIDs: false },
+                       { collapseGroups: false },
+                       { convertTransform: false }
+               ],
+               js2svg: { pretty: true }
+       } );
+
+// Make the directory for the svgs
+if ( !fs.existsSync( dirname ) ) {
+       fs.mkdirSync( dirname );
+}
+
+fs.readFile( symbolsFile, function ( err, data ) {
+
+       function makeRequest( symbol ) {
+               var request,
+                       data = querystring.stringify( {
+                               q: symbol
+                       } ),
+                       // API call to mathoid
+                       options = {
+                               host: 'localhost',
+                               port: '10042',
+                               path: '/',
+                               method: 'POST',
+                               headers: {
+                                       'Content-Type': 
'application/x-www-form-urlencoded',
+                                       'Content-Length': Buffer.byteLength( 
data )
+                               }
+                       };
+
+               // Populate and make the API call
+               request = http.request( options, function ( res ) {
+                       var body = '';
+                       res.setEncoding( 'utf8' );
+
+                       res.on( 'data', function ( data ) {
+                               body += data;
+                       } );
+
+                       res.on( 'end', function () {
+                               var classname, filename, svg;
+                               // Make the classname, replacing any 
non-alphanumerics with their ASCII order
+                               classname = symbol.replace( /[^\w]/g, function 
( c ) {
+                                       return '_' + c.charCodeAt( 0 );
+                               } );
+                               // Make the filename, also adding the path and 
the extension
+                               filename = dirname + '/' + md5( symbol ) + 
'.svg';
+
+                               svg = JSON.parse( body ).svg;
+
+                               if ( !svg ) {
+                                       console.log( symbol + ' FAILED: ' + 
body );
+                                       onEnd();
+                                       return;
+                               }
+
+                               svgo.optimize( svg, function ( result ) {
+                                       // Write the svg to the svg file
+                                       fs.writeFile( filename, result.data );
+                                       // write to the css file
+                                       fs.appendFile( cssFile, '\n.' + 
classname + ' {\n\tbackground-image: url(' + filename + ');\n}\n' );
+                               } );
+                               console.log( symbol + ' -> ' + filename );
+                               onEnd();
+
+                       } );
+               } );
+               request.setTimeout( 10000 );
+               request.write( data );
+               request.end();
+               runNext();
+       }
+
+       function onEnd() {
+               count--;
+               runNext();
+       }
+
+       function runNext() {
+               if ( count < 1 && symbolList.length ) {
+                       count++;
+                       makeRequest( symbolList.shift() );
+               }
+       }
+
+       symbolObject = JSON.parse( data.toString() );
+       for ( group in symbolObject ) {
+               symbols = symbolObject[ group ];
+               for ( i = 0; i < symbols.length; i++ ) {
+                       symbolList.push( symbols[ i ].tex );
+               }
+       }
+
+       fs.writeFile( cssFile, '/*!\n * This file is GENERATED by 
tools/getSvgsAndCss.js\n * DO NOT EDIT\n */\n' );
+       count = 0;
+       runNext();
+
+} );
diff --git a/modules/ve-math/tools/package.json 
b/modules/ve-math/tools/package.json
new file mode 100644
index 0000000..467d9c1
--- /dev/null
+++ b/modules/ve-math/tools/package.json
@@ -0,0 +1,7 @@
+{
+  "name": "math-icons-generator",
+  "dependencies": {
+    "md5": "^2.0.0",
+    "svgo": "^0.6.0"
+  }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/252891
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa792418d870a7e266b6455ef037994e31278278
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Tchanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to