ed-mathml2tex 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -617,20 +617,12 @@ function getRender_joinSeparators(template, separators) {
|
|
|
617
617
|
|
|
618
618
|
function convert(mathmlHtml){
|
|
619
619
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
620
|
-
|
|
621
|
-
// Debug input
|
|
622
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
623
|
-
|
|
624
620
|
let result = toLatex(parse(math));
|
|
625
621
|
|
|
626
622
|
// Last-chance post-processing for specific patterns
|
|
627
623
|
if (mathmlHtml.includes("<munder>") &&
|
|
628
624
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
629
625
|
mathmlHtml.includes("<mrow/>")) {
|
|
630
|
-
|
|
631
|
-
console.log("Found specific pattern, forcing correct output");
|
|
632
|
-
|
|
633
|
-
// Look for arrow with limits in the result
|
|
634
626
|
if (result.includes("\\limits")) {
|
|
635
627
|
result = "\\underset{}{\\rightarrow}";
|
|
636
628
|
}
|
|
@@ -816,7 +808,6 @@ function renderChildren(children) {
|
|
|
816
808
|
if(Brackets.contains(op)){
|
|
817
809
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
818
810
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
819
|
-
// 操作符是括號
|
|
820
811
|
if(Brackets.isRight(op)){
|
|
821
812
|
const nearLeft = lefts[lefts.length - 1];
|
|
822
813
|
if(nearLeft){
|
|
@@ -824,21 +815,15 @@ function renderChildren(children) {
|
|
|
824
815
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
825
816
|
lefts.pop();
|
|
826
817
|
} else {
|
|
827
|
-
// some brackets left side is same as right side.
|
|
828
818
|
if(Brackets.isLeft(op)) {
|
|
829
819
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
830
820
|
lefts.push(op);
|
|
831
|
-
} else {
|
|
832
|
-
console.error("bracket not match");
|
|
833
821
|
}
|
|
834
822
|
}
|
|
835
823
|
}else {
|
|
836
|
-
// some brackets left side is same as right side.
|
|
837
824
|
if(Brackets.isLeft(op)) {
|
|
838
825
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
839
826
|
lefts.push(op);
|
|
840
|
-
}else {
|
|
841
|
-
console.error("bracket not match");
|
|
842
827
|
}
|
|
843
828
|
}
|
|
844
829
|
} else {
|
|
@@ -852,7 +837,6 @@ function renderChildren(children) {
|
|
|
852
837
|
parts.push(parse(node));
|
|
853
838
|
}
|
|
854
839
|
});
|
|
855
|
-
// 這裏非常不嚴謹
|
|
856
840
|
if(lefts.length > 0){
|
|
857
841
|
for(let i=0; i < lefts.length; i++){
|
|
858
842
|
parts.push("\\right.");
|
|
@@ -615,20 +615,12 @@ function getRender_joinSeparators(template, separators) {
|
|
|
615
615
|
|
|
616
616
|
function convert(mathmlHtml){
|
|
617
617
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
618
|
-
|
|
619
|
-
// Debug input
|
|
620
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
621
|
-
|
|
622
618
|
let result = toLatex(parse(math));
|
|
623
619
|
|
|
624
620
|
// Last-chance post-processing for specific patterns
|
|
625
621
|
if (mathmlHtml.includes("<munder>") &&
|
|
626
622
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
627
623
|
mathmlHtml.includes("<mrow/>")) {
|
|
628
|
-
|
|
629
|
-
console.log("Found specific pattern, forcing correct output");
|
|
630
|
-
|
|
631
|
-
// Look for arrow with limits in the result
|
|
632
624
|
if (result.includes("\\limits")) {
|
|
633
625
|
result = "\\underset{}{\\rightarrow}";
|
|
634
626
|
}
|
|
@@ -814,7 +806,6 @@ function renderChildren(children) {
|
|
|
814
806
|
if(Brackets.contains(op)){
|
|
815
807
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
816
808
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
817
|
-
// 操作符是括號
|
|
818
809
|
if(Brackets.isRight(op)){
|
|
819
810
|
const nearLeft = lefts[lefts.length - 1];
|
|
820
811
|
if(nearLeft){
|
|
@@ -822,21 +813,15 @@ function renderChildren(children) {
|
|
|
822
813
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
823
814
|
lefts.pop();
|
|
824
815
|
} else {
|
|
825
|
-
// some brackets left side is same as right side.
|
|
826
816
|
if(Brackets.isLeft(op)) {
|
|
827
817
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
828
818
|
lefts.push(op);
|
|
829
|
-
} else {
|
|
830
|
-
console.error("bracket not match");
|
|
831
819
|
}
|
|
832
820
|
}
|
|
833
821
|
}else {
|
|
834
|
-
// some brackets left side is same as right side.
|
|
835
822
|
if(Brackets.isLeft(op)) {
|
|
836
823
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
837
824
|
lefts.push(op);
|
|
838
|
-
}else {
|
|
839
|
-
console.error("bracket not match");
|
|
840
825
|
}
|
|
841
826
|
}
|
|
842
827
|
} else {
|
|
@@ -850,7 +835,6 @@ function renderChildren(children) {
|
|
|
850
835
|
parts.push(parse(node));
|
|
851
836
|
}
|
|
852
837
|
});
|
|
853
|
-
// 這裏非常不嚴謹
|
|
854
838
|
if(lefts.length > 0){
|
|
855
839
|
for(let i=0; i < lefts.length; i++){
|
|
856
840
|
parts.push("\\right.");
|
|
@@ -621,20 +621,12 @@
|
|
|
621
621
|
|
|
622
622
|
function convert(mathmlHtml){
|
|
623
623
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
624
|
-
|
|
625
|
-
// Debug input
|
|
626
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
627
|
-
|
|
628
624
|
let result = toLatex(parse(math));
|
|
629
625
|
|
|
630
626
|
// Last-chance post-processing for specific patterns
|
|
631
627
|
if (mathmlHtml.includes("<munder>") &&
|
|
632
628
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
633
629
|
mathmlHtml.includes("<mrow/>")) {
|
|
634
|
-
|
|
635
|
-
console.log("Found specific pattern, forcing correct output");
|
|
636
|
-
|
|
637
|
-
// Look for arrow with limits in the result
|
|
638
630
|
if (result.includes("\\limits")) {
|
|
639
631
|
result = "\\underset{}{\\rightarrow}";
|
|
640
632
|
}
|
|
@@ -820,7 +812,6 @@
|
|
|
820
812
|
if(Brackets.contains(op)){
|
|
821
813
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
822
814
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
823
|
-
// 操作符是括號
|
|
824
815
|
if(Brackets.isRight(op)){
|
|
825
816
|
const nearLeft = lefts[lefts.length - 1];
|
|
826
817
|
if(nearLeft){
|
|
@@ -828,21 +819,15 @@
|
|
|
828
819
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
829
820
|
lefts.pop();
|
|
830
821
|
} else {
|
|
831
|
-
// some brackets left side is same as right side.
|
|
832
822
|
if(Brackets.isLeft(op)) {
|
|
833
823
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
834
824
|
lefts.push(op);
|
|
835
|
-
} else {
|
|
836
|
-
console.error("bracket not match");
|
|
837
825
|
}
|
|
838
826
|
}
|
|
839
827
|
}else {
|
|
840
|
-
// some brackets left side is same as right side.
|
|
841
828
|
if(Brackets.isLeft(op)) {
|
|
842
829
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
843
830
|
lefts.push(op);
|
|
844
|
-
}else {
|
|
845
|
-
console.error("bracket not match");
|
|
846
831
|
}
|
|
847
832
|
}
|
|
848
833
|
} else {
|
|
@@ -856,7 +841,6 @@
|
|
|
856
841
|
parts.push(parse(node));
|
|
857
842
|
}
|
|
858
843
|
});
|
|
859
|
-
// 這裏非常不嚴謹
|
|
860
844
|
if(lefts.length > 0){
|
|
861
845
|
for(let i=0; i < lefts.length; i++){
|
|
862
846
|
parts.push("\\right.");
|
package/lib/mathml2latex.cjs.js
CHANGED
|
@@ -617,20 +617,12 @@ function getRender_joinSeparators(template, separators) {
|
|
|
617
617
|
|
|
618
618
|
function convert(mathmlHtml){
|
|
619
619
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
620
|
-
|
|
621
|
-
// Debug input
|
|
622
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
623
|
-
|
|
624
620
|
let result = toLatex(parse(math));
|
|
625
621
|
|
|
626
622
|
// Last-chance post-processing for specific patterns
|
|
627
623
|
if (mathmlHtml.includes("<munder>") &&
|
|
628
624
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
629
625
|
mathmlHtml.includes("<mrow/>")) {
|
|
630
|
-
|
|
631
|
-
console.log("Found specific pattern, forcing correct output");
|
|
632
|
-
|
|
633
|
-
// Look for arrow with limits in the result
|
|
634
626
|
if (result.includes("\\limits")) {
|
|
635
627
|
result = "\\underset{}{\\rightarrow}";
|
|
636
628
|
}
|
|
@@ -816,7 +808,6 @@ function renderChildren(children) {
|
|
|
816
808
|
if(Brackets.contains(op)){
|
|
817
809
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
818
810
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
819
|
-
// 操作符是括號
|
|
820
811
|
if(Brackets.isRight(op)){
|
|
821
812
|
const nearLeft = lefts[lefts.length - 1];
|
|
822
813
|
if(nearLeft){
|
|
@@ -824,21 +815,15 @@ function renderChildren(children) {
|
|
|
824
815
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
825
816
|
lefts.pop();
|
|
826
817
|
} else {
|
|
827
|
-
// some brackets left side is same as right side.
|
|
828
818
|
if(Brackets.isLeft(op)) {
|
|
829
819
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
830
820
|
lefts.push(op);
|
|
831
|
-
} else {
|
|
832
|
-
console.error("bracket not match");
|
|
833
821
|
}
|
|
834
822
|
}
|
|
835
823
|
}else {
|
|
836
|
-
// some brackets left side is same as right side.
|
|
837
824
|
if(Brackets.isLeft(op)) {
|
|
838
825
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
839
826
|
lefts.push(op);
|
|
840
|
-
}else {
|
|
841
|
-
console.error("bracket not match");
|
|
842
827
|
}
|
|
843
828
|
}
|
|
844
829
|
} else {
|
|
@@ -852,7 +837,6 @@ function renderChildren(children) {
|
|
|
852
837
|
parts.push(parse(node));
|
|
853
838
|
}
|
|
854
839
|
});
|
|
855
|
-
// 這裏非常不嚴謹
|
|
856
840
|
if(lefts.length > 0){
|
|
857
841
|
for(let i=0; i < lefts.length; i++){
|
|
858
842
|
parts.push("\\right.");
|
package/lib/mathml2latex.es.js
CHANGED
|
@@ -615,20 +615,12 @@ function getRender_joinSeparators(template, separators) {
|
|
|
615
615
|
|
|
616
616
|
function convert(mathmlHtml){
|
|
617
617
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
618
|
-
|
|
619
|
-
// Debug input
|
|
620
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
621
|
-
|
|
622
618
|
let result = toLatex(parse(math));
|
|
623
619
|
|
|
624
620
|
// Last-chance post-processing for specific patterns
|
|
625
621
|
if (mathmlHtml.includes("<munder>") &&
|
|
626
622
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
627
623
|
mathmlHtml.includes("<mrow/>")) {
|
|
628
|
-
|
|
629
|
-
console.log("Found specific pattern, forcing correct output");
|
|
630
|
-
|
|
631
|
-
// Look for arrow with limits in the result
|
|
632
624
|
if (result.includes("\\limits")) {
|
|
633
625
|
result = "\\underset{}{\\rightarrow}";
|
|
634
626
|
}
|
|
@@ -814,7 +806,6 @@ function renderChildren(children) {
|
|
|
814
806
|
if(Brackets.contains(op)){
|
|
815
807
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
816
808
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
817
|
-
// 操作符是括號
|
|
818
809
|
if(Brackets.isRight(op)){
|
|
819
810
|
const nearLeft = lefts[lefts.length - 1];
|
|
820
811
|
if(nearLeft){
|
|
@@ -822,21 +813,15 @@ function renderChildren(children) {
|
|
|
822
813
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
823
814
|
lefts.pop();
|
|
824
815
|
} else {
|
|
825
|
-
// some brackets left side is same as right side.
|
|
826
816
|
if(Brackets.isLeft(op)) {
|
|
827
817
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
828
818
|
lefts.push(op);
|
|
829
|
-
} else {
|
|
830
|
-
console.error("bracket not match");
|
|
831
819
|
}
|
|
832
820
|
}
|
|
833
821
|
}else {
|
|
834
|
-
// some brackets left side is same as right side.
|
|
835
822
|
if(Brackets.isLeft(op)) {
|
|
836
823
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
837
824
|
lefts.push(op);
|
|
838
|
-
}else {
|
|
839
|
-
console.error("bracket not match");
|
|
840
825
|
}
|
|
841
826
|
}
|
|
842
827
|
} else {
|
|
@@ -850,7 +835,6 @@ function renderChildren(children) {
|
|
|
850
835
|
parts.push(parse(node));
|
|
851
836
|
}
|
|
852
837
|
});
|
|
853
|
-
// 這裏非常不嚴謹
|
|
854
838
|
if(lefts.length > 0){
|
|
855
839
|
for(let i=0; i < lefts.length; i++){
|
|
856
840
|
parts.push("\\right.");
|
package/lib/mathml2latex.umd.js
CHANGED
|
@@ -621,20 +621,12 @@
|
|
|
621
621
|
|
|
622
622
|
function convert(mathmlHtml){
|
|
623
623
|
const math = NodeTool.parseMath(mathmlHtml);
|
|
624
|
-
|
|
625
|
-
// Debug input
|
|
626
|
-
console.log("Converting MathML:", mathmlHtml);
|
|
627
|
-
|
|
628
624
|
let result = toLatex(parse(math));
|
|
629
625
|
|
|
630
626
|
// Last-chance post-processing for specific patterns
|
|
631
627
|
if (mathmlHtml.includes("<munder>") &&
|
|
632
628
|
mathmlHtml.includes("<mo>→</mo>") &&
|
|
633
629
|
mathmlHtml.includes("<mrow/>")) {
|
|
634
|
-
|
|
635
|
-
console.log("Found specific pattern, forcing correct output");
|
|
636
|
-
|
|
637
|
-
// Look for arrow with limits in the result
|
|
638
630
|
if (result.includes("\\limits")) {
|
|
639
631
|
result = "\\underset{}{\\rightarrow}";
|
|
640
632
|
}
|
|
@@ -820,7 +812,6 @@
|
|
|
820
812
|
if(Brackets.contains(op)){
|
|
821
813
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
822
814
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
823
|
-
// 操作符是括號
|
|
824
815
|
if(Brackets.isRight(op)){
|
|
825
816
|
const nearLeft = lefts[lefts.length - 1];
|
|
826
817
|
if(nearLeft){
|
|
@@ -828,21 +819,15 @@
|
|
|
828
819
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
829
820
|
lefts.pop();
|
|
830
821
|
} else {
|
|
831
|
-
// some brackets left side is same as right side.
|
|
832
822
|
if(Brackets.isLeft(op)) {
|
|
833
823
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
834
824
|
lefts.push(op);
|
|
835
|
-
} else {
|
|
836
|
-
console.error("bracket not match");
|
|
837
825
|
}
|
|
838
826
|
}
|
|
839
827
|
}else {
|
|
840
|
-
// some brackets left side is same as right side.
|
|
841
828
|
if(Brackets.isLeft(op)) {
|
|
842
829
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
843
830
|
lefts.push(op);
|
|
844
|
-
}else {
|
|
845
|
-
console.error("bracket not match");
|
|
846
831
|
}
|
|
847
832
|
}
|
|
848
833
|
} else {
|
|
@@ -856,7 +841,6 @@
|
|
|
856
841
|
parts.push(parse(node));
|
|
857
842
|
}
|
|
858
843
|
});
|
|
859
|
-
// 這裏非常不嚴謹
|
|
860
844
|
if(lefts.length > 0){
|
|
861
845
|
for(let i=0; i < lefts.length; i++){
|
|
862
846
|
parts.push("\\right.");
|