ed-mathml2tex 0.0.9 → 0.1.0
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.
- package/lib/mathml2latex.browser.cjs.js +17 -16
- package/lib/mathml2latex.browser.es.js +17 -16
- package/lib/mathml2latex.browser.umd.js +17 -16
- package/lib/mathml2latex.cjs.js +17 -16
- package/lib/mathml2latex.es.js +17 -16
- package/lib/mathml2latex.umd.js +17 -16
- package/package.json +1 -1
|
@@ -791,6 +791,7 @@ function renderChildren(children) {
|
|
|
791
791
|
if(Brackets.contains(op)){
|
|
792
792
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
793
793
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
794
|
+
|
|
794
795
|
if(Brackets.isRight(op)){
|
|
795
796
|
const nearLeft = lefts[lefts.length - 1];
|
|
796
797
|
if(nearLeft){
|
|
@@ -798,16 +799,10 @@ function renderChildren(children) {
|
|
|
798
799
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
799
800
|
lefts.pop();
|
|
800
801
|
} else {
|
|
801
|
-
|
|
802
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
803
|
-
lefts.push(op);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
}else {
|
|
807
|
-
if(Brackets.isLeft(op)) {
|
|
808
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
809
|
-
lefts.push(op);
|
|
802
|
+
parts.push(`\\right${op}`);
|
|
810
803
|
}
|
|
804
|
+
} else {
|
|
805
|
+
parts.push(`\\right${op}`);
|
|
811
806
|
}
|
|
812
807
|
} else {
|
|
813
808
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -820,10 +815,9 @@ function renderChildren(children) {
|
|
|
820
815
|
parts.push(parse(node));
|
|
821
816
|
}
|
|
822
817
|
});
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
}
|
|
818
|
+
// Only add \right. if there are unmatched left brackets
|
|
819
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
820
|
+
parts.push("\\right.");
|
|
827
821
|
}
|
|
828
822
|
lefts = undefined;
|
|
829
823
|
return parts;
|
|
@@ -954,14 +948,21 @@ function renderMfenced(node, children) {
|
|
|
954
948
|
const parts = renderChildren(children);
|
|
955
949
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
956
950
|
|
|
951
|
+
// Handle nested absolute value cases
|
|
952
|
+
if (open === '|' && close === '') {
|
|
953
|
+
return `\\left|${content}`;
|
|
954
|
+
}
|
|
955
|
+
if (open === '' && close === '|') {
|
|
956
|
+
return `${content}\\right|`;
|
|
957
|
+
}
|
|
958
|
+
|
|
957
959
|
// Handle system of equations with curly brace
|
|
958
960
|
if (open === '{') {
|
|
959
|
-
// If no closing brace specified, use \right.
|
|
960
961
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
961
962
|
}
|
|
962
963
|
|
|
963
|
-
// Handle absolute value notation
|
|
964
|
-
if (open === '|' &&
|
|
964
|
+
// Handle regular absolute value notation
|
|
965
|
+
if (open === '|' && close === '|') {
|
|
965
966
|
return `\\left|${content}\\right|`;
|
|
966
967
|
}
|
|
967
968
|
|
|
@@ -789,6 +789,7 @@ function renderChildren(children) {
|
|
|
789
789
|
if(Brackets.contains(op)){
|
|
790
790
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
791
791
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
792
|
+
|
|
792
793
|
if(Brackets.isRight(op)){
|
|
793
794
|
const nearLeft = lefts[lefts.length - 1];
|
|
794
795
|
if(nearLeft){
|
|
@@ -796,16 +797,10 @@ function renderChildren(children) {
|
|
|
796
797
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
797
798
|
lefts.pop();
|
|
798
799
|
} else {
|
|
799
|
-
|
|
800
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
801
|
-
lefts.push(op);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}else {
|
|
805
|
-
if(Brackets.isLeft(op)) {
|
|
806
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
807
|
-
lefts.push(op);
|
|
800
|
+
parts.push(`\\right${op}`);
|
|
808
801
|
}
|
|
802
|
+
} else {
|
|
803
|
+
parts.push(`\\right${op}`);
|
|
809
804
|
}
|
|
810
805
|
} else {
|
|
811
806
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -818,10 +813,9 @@ function renderChildren(children) {
|
|
|
818
813
|
parts.push(parse(node));
|
|
819
814
|
}
|
|
820
815
|
});
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
816
|
+
// Only add \right. if there are unmatched left brackets
|
|
817
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
818
|
+
parts.push("\\right.");
|
|
825
819
|
}
|
|
826
820
|
lefts = undefined;
|
|
827
821
|
return parts;
|
|
@@ -952,14 +946,21 @@ function renderMfenced(node, children) {
|
|
|
952
946
|
const parts = renderChildren(children);
|
|
953
947
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
954
948
|
|
|
949
|
+
// Handle nested absolute value cases
|
|
950
|
+
if (open === '|' && close === '') {
|
|
951
|
+
return `\\left|${content}`;
|
|
952
|
+
}
|
|
953
|
+
if (open === '' && close === '|') {
|
|
954
|
+
return `${content}\\right|`;
|
|
955
|
+
}
|
|
956
|
+
|
|
955
957
|
// Handle system of equations with curly brace
|
|
956
958
|
if (open === '{') {
|
|
957
|
-
// If no closing brace specified, use \right.
|
|
958
959
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
959
960
|
}
|
|
960
961
|
|
|
961
|
-
// Handle absolute value notation
|
|
962
|
-
if (open === '|' &&
|
|
962
|
+
// Handle regular absolute value notation
|
|
963
|
+
if (open === '|' && close === '|') {
|
|
963
964
|
return `\\left|${content}\\right|`;
|
|
964
965
|
}
|
|
965
966
|
|
|
@@ -795,6 +795,7 @@
|
|
|
795
795
|
if(Brackets.contains(op)){
|
|
796
796
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
797
797
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
798
|
+
|
|
798
799
|
if(Brackets.isRight(op)){
|
|
799
800
|
const nearLeft = lefts[lefts.length - 1];
|
|
800
801
|
if(nearLeft){
|
|
@@ -802,16 +803,10 @@
|
|
|
802
803
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
803
804
|
lefts.pop();
|
|
804
805
|
} else {
|
|
805
|
-
|
|
806
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
807
|
-
lefts.push(op);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}else {
|
|
811
|
-
if(Brackets.isLeft(op)) {
|
|
812
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
813
|
-
lefts.push(op);
|
|
806
|
+
parts.push(`\\right${op}`);
|
|
814
807
|
}
|
|
808
|
+
} else {
|
|
809
|
+
parts.push(`\\right${op}`);
|
|
815
810
|
}
|
|
816
811
|
} else {
|
|
817
812
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -824,10 +819,9 @@
|
|
|
824
819
|
parts.push(parse(node));
|
|
825
820
|
}
|
|
826
821
|
});
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
822
|
+
// Only add \right. if there are unmatched left brackets
|
|
823
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
824
|
+
parts.push("\\right.");
|
|
831
825
|
}
|
|
832
826
|
lefts = undefined;
|
|
833
827
|
return parts;
|
|
@@ -958,14 +952,21 @@
|
|
|
958
952
|
const parts = renderChildren(children);
|
|
959
953
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
960
954
|
|
|
955
|
+
// Handle nested absolute value cases
|
|
956
|
+
if (open === '|' && close === '') {
|
|
957
|
+
return `\\left|${content}`;
|
|
958
|
+
}
|
|
959
|
+
if (open === '' && close === '|') {
|
|
960
|
+
return `${content}\\right|`;
|
|
961
|
+
}
|
|
962
|
+
|
|
961
963
|
// Handle system of equations with curly brace
|
|
962
964
|
if (open === '{') {
|
|
963
|
-
// If no closing brace specified, use \right.
|
|
964
965
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
965
966
|
}
|
|
966
967
|
|
|
967
|
-
// Handle absolute value notation
|
|
968
|
-
if (open === '|' &&
|
|
968
|
+
// Handle regular absolute value notation
|
|
969
|
+
if (open === '|' && close === '|') {
|
|
969
970
|
return `\\left|${content}\\right|`;
|
|
970
971
|
}
|
|
971
972
|
|
package/lib/mathml2latex.cjs.js
CHANGED
|
@@ -791,6 +791,7 @@ function renderChildren(children) {
|
|
|
791
791
|
if(Brackets.contains(op)){
|
|
792
792
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
793
793
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
794
|
+
|
|
794
795
|
if(Brackets.isRight(op)){
|
|
795
796
|
const nearLeft = lefts[lefts.length - 1];
|
|
796
797
|
if(nearLeft){
|
|
@@ -798,16 +799,10 @@ function renderChildren(children) {
|
|
|
798
799
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
799
800
|
lefts.pop();
|
|
800
801
|
} else {
|
|
801
|
-
|
|
802
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
803
|
-
lefts.push(op);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
}else {
|
|
807
|
-
if(Brackets.isLeft(op)) {
|
|
808
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
809
|
-
lefts.push(op);
|
|
802
|
+
parts.push(`\\right${op}`);
|
|
810
803
|
}
|
|
804
|
+
} else {
|
|
805
|
+
parts.push(`\\right${op}`);
|
|
811
806
|
}
|
|
812
807
|
} else {
|
|
813
808
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -820,10 +815,9 @@ function renderChildren(children) {
|
|
|
820
815
|
parts.push(parse(node));
|
|
821
816
|
}
|
|
822
817
|
});
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
}
|
|
818
|
+
// Only add \right. if there are unmatched left brackets
|
|
819
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
820
|
+
parts.push("\\right.");
|
|
827
821
|
}
|
|
828
822
|
lefts = undefined;
|
|
829
823
|
return parts;
|
|
@@ -954,14 +948,21 @@ function renderMfenced(node, children) {
|
|
|
954
948
|
const parts = renderChildren(children);
|
|
955
949
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
956
950
|
|
|
951
|
+
// Handle nested absolute value cases
|
|
952
|
+
if (open === '|' && close === '') {
|
|
953
|
+
return `\\left|${content}`;
|
|
954
|
+
}
|
|
955
|
+
if (open === '' && close === '|') {
|
|
956
|
+
return `${content}\\right|`;
|
|
957
|
+
}
|
|
958
|
+
|
|
957
959
|
// Handle system of equations with curly brace
|
|
958
960
|
if (open === '{') {
|
|
959
|
-
// If no closing brace specified, use \right.
|
|
960
961
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
961
962
|
}
|
|
962
963
|
|
|
963
|
-
// Handle absolute value notation
|
|
964
|
-
if (open === '|' &&
|
|
964
|
+
// Handle regular absolute value notation
|
|
965
|
+
if (open === '|' && close === '|') {
|
|
965
966
|
return `\\left|${content}\\right|`;
|
|
966
967
|
}
|
|
967
968
|
|
package/lib/mathml2latex.es.js
CHANGED
|
@@ -789,6 +789,7 @@ function renderChildren(children) {
|
|
|
789
789
|
if(Brackets.contains(op)){
|
|
790
790
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
791
791
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
792
|
+
|
|
792
793
|
if(Brackets.isRight(op)){
|
|
793
794
|
const nearLeft = lefts[lefts.length - 1];
|
|
794
795
|
if(nearLeft){
|
|
@@ -796,16 +797,10 @@ function renderChildren(children) {
|
|
|
796
797
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
797
798
|
lefts.pop();
|
|
798
799
|
} else {
|
|
799
|
-
|
|
800
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
801
|
-
lefts.push(op);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}else {
|
|
805
|
-
if(Brackets.isLeft(op)) {
|
|
806
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
807
|
-
lefts.push(op);
|
|
800
|
+
parts.push(`\\right${op}`);
|
|
808
801
|
}
|
|
802
|
+
} else {
|
|
803
|
+
parts.push(`\\right${op}`);
|
|
809
804
|
}
|
|
810
805
|
} else {
|
|
811
806
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -818,10 +813,9 @@ function renderChildren(children) {
|
|
|
818
813
|
parts.push(parse(node));
|
|
819
814
|
}
|
|
820
815
|
});
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
816
|
+
// Only add \right. if there are unmatched left brackets
|
|
817
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
818
|
+
parts.push("\\right.");
|
|
825
819
|
}
|
|
826
820
|
lefts = undefined;
|
|
827
821
|
return parts;
|
|
@@ -952,14 +946,21 @@ function renderMfenced(node, children) {
|
|
|
952
946
|
const parts = renderChildren(children);
|
|
953
947
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
954
948
|
|
|
949
|
+
// Handle nested absolute value cases
|
|
950
|
+
if (open === '|' && close === '') {
|
|
951
|
+
return `\\left|${content}`;
|
|
952
|
+
}
|
|
953
|
+
if (open === '' && close === '|') {
|
|
954
|
+
return `${content}\\right|`;
|
|
955
|
+
}
|
|
956
|
+
|
|
955
957
|
// Handle system of equations with curly brace
|
|
956
958
|
if (open === '{') {
|
|
957
|
-
// If no closing brace specified, use \right.
|
|
958
959
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
959
960
|
}
|
|
960
961
|
|
|
961
|
-
// Handle absolute value notation
|
|
962
|
-
if (open === '|' &&
|
|
962
|
+
// Handle regular absolute value notation
|
|
963
|
+
if (open === '|' && close === '|') {
|
|
963
964
|
return `\\left|${content}\\right|`;
|
|
964
965
|
}
|
|
965
966
|
|
package/lib/mathml2latex.umd.js
CHANGED
|
@@ -795,6 +795,7 @@
|
|
|
795
795
|
if(Brackets.contains(op)){
|
|
796
796
|
let stretchy = NodeTool.getAttr(node, 'stretchy', 'true');
|
|
797
797
|
stretchy = ['', 'true'].indexOf(stretchy) > -1;
|
|
798
|
+
|
|
798
799
|
if(Brackets.isRight(op)){
|
|
799
800
|
const nearLeft = lefts[lefts.length - 1];
|
|
800
801
|
if(nearLeft){
|
|
@@ -802,16 +803,10 @@
|
|
|
802
803
|
parts.push(Brackets.parseRight(op, stretchy));
|
|
803
804
|
lefts.pop();
|
|
804
805
|
} else {
|
|
805
|
-
|
|
806
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
807
|
-
lefts.push(op);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}else {
|
|
811
|
-
if(Brackets.isLeft(op)) {
|
|
812
|
-
parts.push(Brackets.parseLeft(op, stretchy));
|
|
813
|
-
lefts.push(op);
|
|
806
|
+
parts.push(`\\right${op}`);
|
|
814
807
|
}
|
|
808
|
+
} else {
|
|
809
|
+
parts.push(`\\right${op}`);
|
|
815
810
|
}
|
|
816
811
|
} else {
|
|
817
812
|
parts.push(Brackets.parseLeft(op, stretchy));
|
|
@@ -824,10 +819,9 @@
|
|
|
824
819
|
parts.push(parse(node));
|
|
825
820
|
}
|
|
826
821
|
});
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
822
|
+
// Only add \right. if there are unmatched left brackets
|
|
823
|
+
if(lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
824
|
+
parts.push("\\right.");
|
|
831
825
|
}
|
|
832
826
|
lefts = undefined;
|
|
833
827
|
return parts;
|
|
@@ -958,14 +952,21 @@
|
|
|
958
952
|
const parts = renderChildren(children);
|
|
959
953
|
const content = parts.join(separatorsStr === '|' ? ',' : separatorsStr).trim();
|
|
960
954
|
|
|
955
|
+
// Handle nested absolute value cases
|
|
956
|
+
if (open === '|' && close === '') {
|
|
957
|
+
return `\\left|${content}`;
|
|
958
|
+
}
|
|
959
|
+
if (open === '' && close === '|') {
|
|
960
|
+
return `${content}\\right|`;
|
|
961
|
+
}
|
|
962
|
+
|
|
961
963
|
// Handle system of equations with curly brace
|
|
962
964
|
if (open === '{') {
|
|
963
|
-
// If no closing brace specified, use \right.
|
|
964
965
|
return `\\left\\{${content}${close ? '\\right\\}' : '\\right.'}`;
|
|
965
966
|
}
|
|
966
967
|
|
|
967
|
-
// Handle absolute value notation
|
|
968
|
-
if (open === '|' &&
|
|
968
|
+
// Handle regular absolute value notation
|
|
969
|
+
if (open === '|' && close === '|') {
|
|
969
970
|
return `\\left|${content}\\right|`;
|
|
970
971
|
}
|
|
971
972
|
|