From aedd5906b24483b30ae836de53dd588889138d4f Mon Sep 17 00:00:00 2001 From: ray <70ray@users.noreply.github.com> Date: Fri, 28 Dec 2018 09:20:31 +0000 Subject: [PATCH] prime and superscript on same character enabled A new symbol 'superScript' defined and used in compoundTerm new unit tests added for this --- TeXZilla.jison | 32 +++++++++++++++++--------------- unit-tests.js | 4 ++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/TeXZilla.jison b/TeXZilla.jison index 3e83ec1..8c1c258 100644 --- a/TeXZilla.jison +++ b/TeXZilla.jison @@ -843,31 +843,33 @@ closedTermList } ; +superScript + : "^" closedTerm { + $$ = $2; +} + | OPP { + $$ = newMo($1); +} + | OPP "^" closedTerm { + $$ = newTag("mrow", newMo($1) + $3); +}; + /* compound terms (closed terms with scripts) */ compoundTerm : TENSOR closedTerm subsupList { $$ = newTag("mmultiscripts", $2 + $3); } - | closedTerm "_" closedTerm "^" closedTerm { - $$ = newScript(false, $1, $3, $5); + | closedTerm "_" closedTerm superScript { + $$ = newScript(false, $1, $3, $4); } - | closedTerm "_" closedTerm OPP { - $$ = newScript(false, $1, $3, newMo($4)); - } - | closedTerm "^" closedTerm "_" closedTerm { - $$ = newScript(false, $1, $5, $3); - } - | closedTerm OPP "_" closedTerm { - $$ = newScript(false, $1, $4, newMo($2)); + | closedTerm superScript "_" closedTerm { + $$ = newScript(false, $1, $4, $2); } | closedTerm "_" closedTerm { $$ = newScript(false, $1, $3, null); } - | closedTerm "^" closedTerm { - $$ = newScript(false, $1, null, $3); - } - | closedTerm OPP { - $$ = newScript(false, $1, null, newMo($2)); + | closedTerm superScript { + $$ = newScript(false, $1, null, $2); } | closedTerm { $$ = $1; } | opm "_" closedTerm "^" closedTerm { diff --git a/unit-tests.js b/unit-tests.js index 1c214d7..f070172 100644 --- a/unit-tests.js +++ b/unit-tests.js @@ -37,6 +37,10 @@ var tests = [ ["a_{b c}^{d e}", 'abcdea_{b c}^{d e}'], /* subscripts and primes */ ["a_1' + b'_2 = c'", 'a1+b2=ca_1\' + b\'_2 = c\''], + /* primes and superscripts */ + ["a'^b", 'aba\'^b'], + ["a'^{bc}_2", 'a2bca\'^{bc}_2'], + ["a_2'^b", 'a2ba_2\'^b'], /* Functions */ ["\\arccos \\arcsin \\arctan \\arg \\cos \\cosh \\cot \\coth \\csc \\deg \\dim \\exp \\hom \\ker \\lg \\ln \\log \\sec \\sin \\sinh \\tan \\tanh \\det \\gcd \\inf \\lim \\liminf \\limsup \\max \\min \\Pr \\sup", 'arccosarcsinarctanargcoscoshcotcothcscdegdimexphomkerlglnlogsecsinsinhtantanhdetgcdinflimliminflimsupmaxminPrsup\\arccos \\arcsin \\arctan \\arg \\cos \\cosh \\cot \\coth \\csc \\deg \\dim \\exp \\hom \\ker \\lg \\ln \\log \\sec \\sin \\sinh \\tan \\tanh \\det \\gcd \\inf \\lim \\liminf \\limsup \\max \\min \\Pr \\sup'], ["\\arccos_1 \\arcsin^2 \\arctan_1^2 \\arg^2_1 \\cos_1 \\cosh^2 \\cot_1^2 \\coth^2_1 \\csc_1 \\deg^2 \\dim_1^2 \\exp^2_1 \\hom_1 \\ker^2 \\lg_1^2 \\ln^2_1 \\log_1 \\sec^2 \\sin_1^2 \\sinh^2_1 \\tan_1 \\tanh^2 \\det_1^2 \\gcd^2_1 \\inf_1 \\lim^2 \\liminf_1^2 \\limsup^2_1 \\max_1 \\min^2 \\Pr_1^2 \\sup^2_1", 'arccos1arcsin2arctan12arg12cos1cosh2cot12coth12csc1deg2dim12exp12hom1ker2lg12ln12log1sec2sin12sinh12tan1tanh2det12gcd12inf1lim2liminf12limsup12max1min2Pr12sup12\\arccos_1 \\arcsin^2 \\arctan_1^2 \\arg^2_1 \\cos_1 \\cosh^2 \\cot_1^2 \\coth^2_1 \\csc_1 \\deg^2 \\dim_1^2 \\exp^2_1 \\hom_1 \\ker^2 \\lg_1^2 \\ln^2_1 \\log_1 \\sec^2 \\sin_1^2 \\sinh^2_1 \\tan_1 \\tanh^2 \\det_1^2 \\gcd^2_1 \\inf_1 \\lim^2 \\liminf_1^2 \\limsup^2_1 \\max_1 \\min^2 \\Pr_1^2 \\sup^2_1'],