ed-mathml2tex 0.1.1 → 0.1.3
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 +51 -15
- package/lib/mathml2latex.browser.es.js +51 -15
- package/lib/mathml2latex.browser.umd.js +51 -15
- package/lib/mathml2latex.cjs.js +51 -15
- package/lib/mathml2latex.es.js +51 -15
- package/lib/mathml2latex.umd.js +51 -15
- package/package.json +1 -1
|
@@ -820,22 +820,43 @@ function renderChildren(children) {
|
|
|
820
820
|
const nearLeft = lefts[lefts.length - 1];
|
|
821
821
|
if (nearLeft) {
|
|
822
822
|
if (Brackets.isPair(nearLeft, op)) {
|
|
823
|
-
|
|
823
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
824
|
+
const parentNode = node.parentNode;
|
|
825
|
+
const nextSibling = node.nextSibling;
|
|
826
|
+
const prevSibling = node.previousSibling;
|
|
827
|
+
|
|
828
|
+
const isInPower = parentNode && (
|
|
829
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
830
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
831
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
832
|
+
);
|
|
833
|
+
|
|
834
|
+
if (isInPower) {
|
|
835
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
836
|
+
} else {
|
|
837
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
838
|
+
}
|
|
824
839
|
lefts.pop();
|
|
825
840
|
} else {
|
|
826
|
-
parts.push(
|
|
841
|
+
parts.push(op);
|
|
827
842
|
}
|
|
828
843
|
} else {
|
|
829
|
-
parts.push(op);
|
|
844
|
+
parts.push(op);
|
|
830
845
|
}
|
|
831
846
|
} else {
|
|
832
|
-
//
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
847
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
848
|
+
const parentNode = node.parentNode;
|
|
849
|
+
const nextSibling = node.nextSibling;
|
|
850
|
+
|
|
851
|
+
const isInPower = parentNode && (
|
|
852
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
853
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
if (isInPower) {
|
|
857
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
837
858
|
} else {
|
|
838
|
-
parts.push(
|
|
859
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
839
860
|
}
|
|
840
861
|
lefts.push(op);
|
|
841
862
|
}
|
|
@@ -847,10 +868,6 @@ function renderChildren(children) {
|
|
|
847
868
|
}
|
|
848
869
|
});
|
|
849
870
|
|
|
850
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
851
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
852
|
-
parts.push("\\right.");
|
|
853
|
-
}
|
|
854
871
|
lefts = undefined;
|
|
855
872
|
return parts;
|
|
856
873
|
}
|
|
@@ -1183,9 +1200,28 @@ function getRender(node) {
|
|
|
1183
1200
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1184
1201
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1185
1202
|
|
|
1203
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1204
|
+
if (open === '|') {
|
|
1205
|
+
const content = childrenArray.map(child => {
|
|
1206
|
+
const parsed = parse(child);
|
|
1207
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1208
|
+
return parsed
|
|
1209
|
+
.replace(/\\left\|/g, '')
|
|
1210
|
+
.replace(/\\right\|/g, '')
|
|
1211
|
+
.replace(/\\left\./g, '')
|
|
1212
|
+
.replace(/\|/g, '');
|
|
1213
|
+
}).join('');
|
|
1214
|
+
|
|
1215
|
+
if (!close) {
|
|
1216
|
+
return `\\left|${content}\\right|`;
|
|
1217
|
+
} else if (close === '|') {
|
|
1218
|
+
return `\\left|${content}\\right|`;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1186
1222
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1187
1223
|
if (open === '{' && !close) {
|
|
1188
|
-
// Kiểm tra xem có
|
|
1224
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1189
1225
|
const hasMtable = childrenArray.some(child => {
|
|
1190
1226
|
// Kiểm tra trực tiếp mtable
|
|
1191
1227
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1229,7 +1265,7 @@ function getRender(node) {
|
|
|
1229
1265
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1230
1266
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1231
1267
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1232
|
-
if (!open) return
|
|
1268
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1233
1269
|
return `\\left${open}${content}\\right${close}`;
|
|
1234
1270
|
};
|
|
1235
1271
|
break;
|
|
@@ -818,22 +818,43 @@ function renderChildren(children) {
|
|
|
818
818
|
const nearLeft = lefts[lefts.length - 1];
|
|
819
819
|
if (nearLeft) {
|
|
820
820
|
if (Brackets.isPair(nearLeft, op)) {
|
|
821
|
-
|
|
821
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
822
|
+
const parentNode = node.parentNode;
|
|
823
|
+
const nextSibling = node.nextSibling;
|
|
824
|
+
const prevSibling = node.previousSibling;
|
|
825
|
+
|
|
826
|
+
const isInPower = parentNode && (
|
|
827
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
828
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
829
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
if (isInPower) {
|
|
833
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
834
|
+
} else {
|
|
835
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
836
|
+
}
|
|
822
837
|
lefts.pop();
|
|
823
838
|
} else {
|
|
824
|
-
parts.push(
|
|
839
|
+
parts.push(op);
|
|
825
840
|
}
|
|
826
841
|
} else {
|
|
827
|
-
parts.push(op);
|
|
842
|
+
parts.push(op);
|
|
828
843
|
}
|
|
829
844
|
} else {
|
|
830
|
-
//
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
845
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
846
|
+
const parentNode = node.parentNode;
|
|
847
|
+
const nextSibling = node.nextSibling;
|
|
848
|
+
|
|
849
|
+
const isInPower = parentNode && (
|
|
850
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
851
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
852
|
+
);
|
|
853
|
+
|
|
854
|
+
if (isInPower) {
|
|
855
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
835
856
|
} else {
|
|
836
|
-
parts.push(
|
|
857
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
837
858
|
}
|
|
838
859
|
lefts.push(op);
|
|
839
860
|
}
|
|
@@ -845,10 +866,6 @@ function renderChildren(children) {
|
|
|
845
866
|
}
|
|
846
867
|
});
|
|
847
868
|
|
|
848
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
849
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
850
|
-
parts.push("\\right.");
|
|
851
|
-
}
|
|
852
869
|
lefts = undefined;
|
|
853
870
|
return parts;
|
|
854
871
|
}
|
|
@@ -1181,9 +1198,28 @@ function getRender(node) {
|
|
|
1181
1198
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1182
1199
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1183
1200
|
|
|
1201
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1202
|
+
if (open === '|') {
|
|
1203
|
+
const content = childrenArray.map(child => {
|
|
1204
|
+
const parsed = parse(child);
|
|
1205
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1206
|
+
return parsed
|
|
1207
|
+
.replace(/\\left\|/g, '')
|
|
1208
|
+
.replace(/\\right\|/g, '')
|
|
1209
|
+
.replace(/\\left\./g, '')
|
|
1210
|
+
.replace(/\|/g, '');
|
|
1211
|
+
}).join('');
|
|
1212
|
+
|
|
1213
|
+
if (!close) {
|
|
1214
|
+
return `\\left|${content}\\right|`;
|
|
1215
|
+
} else if (close === '|') {
|
|
1216
|
+
return `\\left|${content}\\right|`;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1184
1220
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1185
1221
|
if (open === '{' && !close) {
|
|
1186
|
-
// Kiểm tra xem có
|
|
1222
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1187
1223
|
const hasMtable = childrenArray.some(child => {
|
|
1188
1224
|
// Kiểm tra trực tiếp mtable
|
|
1189
1225
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1227,7 +1263,7 @@ function getRender(node) {
|
|
|
1227
1263
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1228
1264
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1229
1265
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1230
|
-
if (!open) return
|
|
1266
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1231
1267
|
return `\\left${open}${content}\\right${close}`;
|
|
1232
1268
|
};
|
|
1233
1269
|
break;
|
|
@@ -824,22 +824,43 @@
|
|
|
824
824
|
const nearLeft = lefts[lefts.length - 1];
|
|
825
825
|
if (nearLeft) {
|
|
826
826
|
if (Brackets.isPair(nearLeft, op)) {
|
|
827
|
-
|
|
827
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
828
|
+
const parentNode = node.parentNode;
|
|
829
|
+
const nextSibling = node.nextSibling;
|
|
830
|
+
const prevSibling = node.previousSibling;
|
|
831
|
+
|
|
832
|
+
const isInPower = parentNode && (
|
|
833
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
834
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
835
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
if (isInPower) {
|
|
839
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
840
|
+
} else {
|
|
841
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
842
|
+
}
|
|
828
843
|
lefts.pop();
|
|
829
844
|
} else {
|
|
830
|
-
parts.push(
|
|
845
|
+
parts.push(op);
|
|
831
846
|
}
|
|
832
847
|
} else {
|
|
833
|
-
parts.push(op);
|
|
848
|
+
parts.push(op);
|
|
834
849
|
}
|
|
835
850
|
} else {
|
|
836
|
-
//
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
851
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
852
|
+
const parentNode = node.parentNode;
|
|
853
|
+
const nextSibling = node.nextSibling;
|
|
854
|
+
|
|
855
|
+
const isInPower = parentNode && (
|
|
856
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
857
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
if (isInPower) {
|
|
861
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
841
862
|
} else {
|
|
842
|
-
parts.push(
|
|
863
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
843
864
|
}
|
|
844
865
|
lefts.push(op);
|
|
845
866
|
}
|
|
@@ -851,10 +872,6 @@
|
|
|
851
872
|
}
|
|
852
873
|
});
|
|
853
874
|
|
|
854
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
855
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
856
|
-
parts.push("\\right.");
|
|
857
|
-
}
|
|
858
875
|
lefts = undefined;
|
|
859
876
|
return parts;
|
|
860
877
|
}
|
|
@@ -1187,9 +1204,28 @@
|
|
|
1187
1204
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1188
1205
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1189
1206
|
|
|
1207
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1208
|
+
if (open === '|') {
|
|
1209
|
+
const content = childrenArray.map(child => {
|
|
1210
|
+
const parsed = parse(child);
|
|
1211
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1212
|
+
return parsed
|
|
1213
|
+
.replace(/\\left\|/g, '')
|
|
1214
|
+
.replace(/\\right\|/g, '')
|
|
1215
|
+
.replace(/\\left\./g, '')
|
|
1216
|
+
.replace(/\|/g, '');
|
|
1217
|
+
}).join('');
|
|
1218
|
+
|
|
1219
|
+
if (!close) {
|
|
1220
|
+
return `\\left|${content}\\right|`;
|
|
1221
|
+
} else if (close === '|') {
|
|
1222
|
+
return `\\left|${content}\\right|`;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1190
1226
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1191
1227
|
if (open === '{' && !close) {
|
|
1192
|
-
// Kiểm tra xem có
|
|
1228
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1193
1229
|
const hasMtable = childrenArray.some(child => {
|
|
1194
1230
|
// Kiểm tra trực tiếp mtable
|
|
1195
1231
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1233,7 +1269,7 @@
|
|
|
1233
1269
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1234
1270
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1235
1271
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1236
|
-
if (!open) return
|
|
1272
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1237
1273
|
return `\\left${open}${content}\\right${close}`;
|
|
1238
1274
|
};
|
|
1239
1275
|
break;
|
package/lib/mathml2latex.cjs.js
CHANGED
|
@@ -820,22 +820,43 @@ function renderChildren(children) {
|
|
|
820
820
|
const nearLeft = lefts[lefts.length - 1];
|
|
821
821
|
if (nearLeft) {
|
|
822
822
|
if (Brackets.isPair(nearLeft, op)) {
|
|
823
|
-
|
|
823
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
824
|
+
const parentNode = node.parentNode;
|
|
825
|
+
const nextSibling = node.nextSibling;
|
|
826
|
+
const prevSibling = node.previousSibling;
|
|
827
|
+
|
|
828
|
+
const isInPower = parentNode && (
|
|
829
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
830
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
831
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
832
|
+
);
|
|
833
|
+
|
|
834
|
+
if (isInPower) {
|
|
835
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
836
|
+
} else {
|
|
837
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
838
|
+
}
|
|
824
839
|
lefts.pop();
|
|
825
840
|
} else {
|
|
826
|
-
parts.push(
|
|
841
|
+
parts.push(op);
|
|
827
842
|
}
|
|
828
843
|
} else {
|
|
829
|
-
parts.push(op);
|
|
844
|
+
parts.push(op);
|
|
830
845
|
}
|
|
831
846
|
} else {
|
|
832
|
-
//
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
847
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
848
|
+
const parentNode = node.parentNode;
|
|
849
|
+
const nextSibling = node.nextSibling;
|
|
850
|
+
|
|
851
|
+
const isInPower = parentNode && (
|
|
852
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
853
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
if (isInPower) {
|
|
857
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
837
858
|
} else {
|
|
838
|
-
parts.push(
|
|
859
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
839
860
|
}
|
|
840
861
|
lefts.push(op);
|
|
841
862
|
}
|
|
@@ -847,10 +868,6 @@ function renderChildren(children) {
|
|
|
847
868
|
}
|
|
848
869
|
});
|
|
849
870
|
|
|
850
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
851
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
852
|
-
parts.push("\\right.");
|
|
853
|
-
}
|
|
854
871
|
lefts = undefined;
|
|
855
872
|
return parts;
|
|
856
873
|
}
|
|
@@ -1183,9 +1200,28 @@ function getRender(node) {
|
|
|
1183
1200
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1184
1201
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1185
1202
|
|
|
1203
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1204
|
+
if (open === '|') {
|
|
1205
|
+
const content = childrenArray.map(child => {
|
|
1206
|
+
const parsed = parse(child);
|
|
1207
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1208
|
+
return parsed
|
|
1209
|
+
.replace(/\\left\|/g, '')
|
|
1210
|
+
.replace(/\\right\|/g, '')
|
|
1211
|
+
.replace(/\\left\./g, '')
|
|
1212
|
+
.replace(/\|/g, '');
|
|
1213
|
+
}).join('');
|
|
1214
|
+
|
|
1215
|
+
if (!close) {
|
|
1216
|
+
return `\\left|${content}\\right|`;
|
|
1217
|
+
} else if (close === '|') {
|
|
1218
|
+
return `\\left|${content}\\right|`;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1186
1222
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1187
1223
|
if (open === '{' && !close) {
|
|
1188
|
-
// Kiểm tra xem có
|
|
1224
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1189
1225
|
const hasMtable = childrenArray.some(child => {
|
|
1190
1226
|
// Kiểm tra trực tiếp mtable
|
|
1191
1227
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1229,7 +1265,7 @@ function getRender(node) {
|
|
|
1229
1265
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1230
1266
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1231
1267
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1232
|
-
if (!open) return
|
|
1268
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1233
1269
|
return `\\left${open}${content}\\right${close}`;
|
|
1234
1270
|
};
|
|
1235
1271
|
break;
|
package/lib/mathml2latex.es.js
CHANGED
|
@@ -818,22 +818,43 @@ function renderChildren(children) {
|
|
|
818
818
|
const nearLeft = lefts[lefts.length - 1];
|
|
819
819
|
if (nearLeft) {
|
|
820
820
|
if (Brackets.isPair(nearLeft, op)) {
|
|
821
|
-
|
|
821
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
822
|
+
const parentNode = node.parentNode;
|
|
823
|
+
const nextSibling = node.nextSibling;
|
|
824
|
+
const prevSibling = node.previousSibling;
|
|
825
|
+
|
|
826
|
+
const isInPower = parentNode && (
|
|
827
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
828
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
829
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
if (isInPower) {
|
|
833
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
834
|
+
} else {
|
|
835
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
836
|
+
}
|
|
822
837
|
lefts.pop();
|
|
823
838
|
} else {
|
|
824
|
-
parts.push(
|
|
839
|
+
parts.push(op);
|
|
825
840
|
}
|
|
826
841
|
} else {
|
|
827
|
-
parts.push(op);
|
|
842
|
+
parts.push(op);
|
|
828
843
|
}
|
|
829
844
|
} else {
|
|
830
|
-
//
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
845
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
846
|
+
const parentNode = node.parentNode;
|
|
847
|
+
const nextSibling = node.nextSibling;
|
|
848
|
+
|
|
849
|
+
const isInPower = parentNode && (
|
|
850
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
851
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
852
|
+
);
|
|
853
|
+
|
|
854
|
+
if (isInPower) {
|
|
855
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
835
856
|
} else {
|
|
836
|
-
parts.push(
|
|
857
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
837
858
|
}
|
|
838
859
|
lefts.push(op);
|
|
839
860
|
}
|
|
@@ -845,10 +866,6 @@ function renderChildren(children) {
|
|
|
845
866
|
}
|
|
846
867
|
});
|
|
847
868
|
|
|
848
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
849
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
850
|
-
parts.push("\\right.");
|
|
851
|
-
}
|
|
852
869
|
lefts = undefined;
|
|
853
870
|
return parts;
|
|
854
871
|
}
|
|
@@ -1181,9 +1198,28 @@ function getRender(node) {
|
|
|
1181
1198
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1182
1199
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1183
1200
|
|
|
1201
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1202
|
+
if (open === '|') {
|
|
1203
|
+
const content = childrenArray.map(child => {
|
|
1204
|
+
const parsed = parse(child);
|
|
1205
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1206
|
+
return parsed
|
|
1207
|
+
.replace(/\\left\|/g, '')
|
|
1208
|
+
.replace(/\\right\|/g, '')
|
|
1209
|
+
.replace(/\\left\./g, '')
|
|
1210
|
+
.replace(/\|/g, '');
|
|
1211
|
+
}).join('');
|
|
1212
|
+
|
|
1213
|
+
if (!close) {
|
|
1214
|
+
return `\\left|${content}\\right|`;
|
|
1215
|
+
} else if (close === '|') {
|
|
1216
|
+
return `\\left|${content}\\right|`;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1184
1220
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1185
1221
|
if (open === '{' && !close) {
|
|
1186
|
-
// Kiểm tra xem có
|
|
1222
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1187
1223
|
const hasMtable = childrenArray.some(child => {
|
|
1188
1224
|
// Kiểm tra trực tiếp mtable
|
|
1189
1225
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1227,7 +1263,7 @@ function getRender(node) {
|
|
|
1227
1263
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1228
1264
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1229
1265
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1230
|
-
if (!open) return
|
|
1266
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1231
1267
|
return `\\left${open}${content}\\right${close}`;
|
|
1232
1268
|
};
|
|
1233
1269
|
break;
|
package/lib/mathml2latex.umd.js
CHANGED
|
@@ -824,22 +824,43 @@
|
|
|
824
824
|
const nearLeft = lefts[lefts.length - 1];
|
|
825
825
|
if (nearLeft) {
|
|
826
826
|
if (Brackets.isPair(nearLeft, op)) {
|
|
827
|
-
|
|
827
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
828
|
+
const parentNode = node.parentNode;
|
|
829
|
+
const nextSibling = node.nextSibling;
|
|
830
|
+
const prevSibling = node.previousSibling;
|
|
831
|
+
|
|
832
|
+
const isInPower = parentNode && (
|
|
833
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
834
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup') ||
|
|
835
|
+
(prevSibling && NodeTool.getNodeName(prevSibling) === 'msup')
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
if (isInPower) {
|
|
839
|
+
parts.push(op); // Không thêm \right cho ngoặc trong mũ
|
|
840
|
+
} else {
|
|
841
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
842
|
+
}
|
|
828
843
|
lefts.pop();
|
|
829
844
|
} else {
|
|
830
|
-
parts.push(
|
|
845
|
+
parts.push(op);
|
|
831
846
|
}
|
|
832
847
|
} else {
|
|
833
|
-
parts.push(op);
|
|
848
|
+
parts.push(op);
|
|
834
849
|
}
|
|
835
850
|
} else {
|
|
836
|
-
//
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
851
|
+
// Kiểm tra cho dấu ngoặc mở
|
|
852
|
+
const parentNode = node.parentNode;
|
|
853
|
+
const nextSibling = node.nextSibling;
|
|
854
|
+
|
|
855
|
+
const isInPower = parentNode && (
|
|
856
|
+
NodeTool.getNodeName(parentNode) === 'msup' ||
|
|
857
|
+
(nextSibling && NodeTool.getNodeName(nextSibling) === 'msup')
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
if (isInPower) {
|
|
861
|
+
parts.push(op); // Không thêm \left cho ngoặc trong mũ
|
|
841
862
|
} else {
|
|
842
|
-
parts.push(
|
|
863
|
+
parts.push(op); // Chỉ thêm dấu ngoặc đơn giản
|
|
843
864
|
}
|
|
844
865
|
lefts.push(op);
|
|
845
866
|
}
|
|
@@ -851,10 +872,6 @@
|
|
|
851
872
|
}
|
|
852
873
|
});
|
|
853
874
|
|
|
854
|
-
// Chỉ thêm \right. nếu có dấu ngoặc mở chưa được đóng
|
|
855
|
-
if (lefts.length > 0 && !parts.some(p => p.includes('\\right'))) {
|
|
856
|
-
parts.push("\\right.");
|
|
857
|
-
}
|
|
858
875
|
lefts = undefined;
|
|
859
876
|
return parts;
|
|
860
877
|
}
|
|
@@ -1187,9 +1204,28 @@
|
|
|
1187
1204
|
const close = NodeTool.getAttr(node, 'close', ')');
|
|
1188
1205
|
const separators = NodeTool.getAttr(node, 'separators', ',').split('');
|
|
1189
1206
|
|
|
1207
|
+
// Xử lý đặc biệt cho trường hợp dấu ngoặc đơn |
|
|
1208
|
+
if (open === '|') {
|
|
1209
|
+
const content = childrenArray.map(child => {
|
|
1210
|
+
const parsed = parse(child);
|
|
1211
|
+
// Loại bỏ các dấu | thừa và các \left|, \right| không cần thiết
|
|
1212
|
+
return parsed
|
|
1213
|
+
.replace(/\\left\|/g, '')
|
|
1214
|
+
.replace(/\\right\|/g, '')
|
|
1215
|
+
.replace(/\\left\./g, '')
|
|
1216
|
+
.replace(/\|/g, '');
|
|
1217
|
+
}).join('');
|
|
1218
|
+
|
|
1219
|
+
if (!close) {
|
|
1220
|
+
return `\\left|${content}\\right|`;
|
|
1221
|
+
} else if (close === '|') {
|
|
1222
|
+
return `\\left|${content}\\right|`;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1190
1226
|
// Xử lý đặc biệt cho mfenced chứa mtable
|
|
1191
1227
|
if (open === '{' && !close) {
|
|
1192
|
-
// Kiểm tra xem có
|
|
1228
|
+
// Kiểm tra xem có phải là một phần của biểu thức mũ không
|
|
1193
1229
|
const hasMtable = childrenArray.some(child => {
|
|
1194
1230
|
// Kiểm tra trực tiếp mtable
|
|
1195
1231
|
if (NodeTool.getNodeName(child) === 'mtable') return true;
|
|
@@ -1233,7 +1269,7 @@
|
|
|
1233
1269
|
if (open === '{' && close === '}') return `\\{${content}\\}`;
|
|
1234
1270
|
if (open === '|' && close === '|') return `\\left|${content}\\right|`;
|
|
1235
1271
|
if (!close) return `\\left${open}${content}\\right.`;
|
|
1236
|
-
if (!open) return
|
|
1272
|
+
if (!open) return `\\left.${content}\\right${close}`;
|
|
1237
1273
|
return `\\left${open}${content}\\right${close}`;
|
|
1238
1274
|
};
|
|
1239
1275
|
break;
|