From a0c040369f2dbe959cc411a2fdd884b137206887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Sat, 23 Mar 2019 11:25:43 +0100 Subject: [PATCH] Replace named space with numeric em values for space commands. See https://github.com/fred-wang/TeXZilla/issues/60 --- TeXZilla.jison | 20 ++++++++++++-------- unit-tests.js | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/TeXZilla.jison b/TeXZilla.jison index ae6a21a..f479bec 100644 --- a/TeXZilla.jison +++ b/TeXZilla.jison @@ -71,6 +71,10 @@ function newMo(aContent, aLeftSpace, aRightSpace) { return tag; } +function newSpace(aWidth) { + return ""; +} + function newScript(aUnderOver, aBase, aScriptBot, aScriptTop) { /* Create a new MathML script element. */ if (aUnderOver) { @@ -697,14 +701,14 @@ closedTerm | SLASH closedTerm { $$ = newTag("menclose", $2, "notation=\"updiagonalstrike\""); } - | QUAD { $$ = ""; } - | QQUAD { $$ = ""; } - | NEGSPACE { $$ = ""; } - | NEGMEDSPACE { $$ = ""; } - | NEGTHICKSPACE { $$ = ""; } - | THINSPACE { $$ = ""; } - | MEDSPACE { $$ = ""; } - | THICKSPACE { $$ = ""; } + | QUAD { $$ = newSpace(1); } + | QQUAD { $$ = newSpace(2); } + | NEGSPACE { $$ = newSpace(namedSpaceToEm("negativethinmathspace")); } + | NEGMEDSPACE { $$ = newSpace(namedSpaceToEm("negativemediummathspace")); } + | NEGTHICKSPACE { $$ = newSpace(namedSpaceToEm("negativethickmathspace")); } + | THINSPACE { $$ = newSpace(namedSpaceToEm("thinmathspace")); } + | MEDSPACE { $$ = newSpace(namedSpaceToEm("mediummathspace")); } + | THICKSPACE { $$ = newSpace(namedSpaceToEm("thickmathspace")); } | SPACE textArg textArg textArg { $$ = ""; diff --git a/unit-tests.js b/unit-tests.js index 442eb7c..de26db8 100644 --- a/unit-tests.js +++ b/unit-tests.js @@ -147,7 +147,7 @@ var tests = [ /* \quad, \qquad */ ["\\quad \\qquad", '\\quad \\qquad'], /* spaces */ - ["\\! \\, \\: \\; \\medspace \\negspace \\negmedspace \\negthickspace \\thickspace \\thinspace", '\\! \\, \\: \\; \\medspace \\negspace \\negmedspace \\negthickspace \\thickspace \\thinspace'], + ["\\! \\, \\: \\; \\medspace \\negspace \\negmedspace \\negthickspace \\thickspace \\thinspace", '\\! \\, \\: \\; \\medspace \\negspace \\negmedspace \\negthickspace \\thickspace \\thinspace'], /* space */ ["\\space{1}{2}{3}", '\\space{1}{2}{3}'], /* mathraisebox */