ed-mathml2tex 0.1.4 → 0.1.5
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 +28 -11
- package/lib/mathml2latex.browser.es.js +28 -11
- package/lib/mathml2latex.browser.umd.js +28 -11
- package/lib/mathml2latex.cjs.js +28 -11
- package/lib/mathml2latex.es.js +28 -11
- package/lib/mathml2latex.umd.js +28 -11
- package/package.json +1 -1
|
@@ -643,15 +643,16 @@ function toLatex(result) {
|
|
|
643
643
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
644
644
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
645
645
|
|
|
646
|
+
// Remove or comment out these lines in toLatex function
|
|
646
647
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
647
|
-
result = result.replace(/≤/g, "\\leq");
|
|
648
|
-
result = result.replace(/≥/g, "\\geq");
|
|
649
|
-
result = result.replace(/≠/g, "\\neq");
|
|
650
|
-
result = result.replace(/≈/g, "\\approx");
|
|
651
|
-
result = result.replace(/π/g, "\\pi");
|
|
652
|
-
result = result.replace(/α/g, "\\alpha");
|
|
653
|
-
result = result.replace(/β/g, "\\beta");
|
|
654
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
648
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
649
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
650
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
651
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
652
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
653
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
654
|
+
// result = result.replace(/β/g, "\\beta");
|
|
655
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
655
656
|
|
|
656
657
|
return result;
|
|
657
658
|
}
|
|
@@ -774,9 +775,25 @@ function parseElementMs(node) {
|
|
|
774
775
|
|
|
775
776
|
// Math Text
|
|
776
777
|
function parseElementMtext(node) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
let content = NodeTool.getNodeText(node)
|
|
779
|
+
// Handle operators and spacing only
|
|
780
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
781
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
782
|
+
.trim();
|
|
783
|
+
|
|
784
|
+
// Handle units with proper \mathrm formatting
|
|
785
|
+
if (content.includes('(') && content.includes(')')) {
|
|
786
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
787
|
+
content = parts.map(part => {
|
|
788
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
789
|
+
// Keep original characters in units
|
|
790
|
+
return `\\mathrm{${part}}`;
|
|
791
|
+
}
|
|
792
|
+
return part;
|
|
793
|
+
}).join('');
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return content;
|
|
780
797
|
}
|
|
781
798
|
|
|
782
799
|
// Math glyph (image)
|
|
@@ -641,15 +641,16 @@ function toLatex(result) {
|
|
|
641
641
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
642
642
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
643
643
|
|
|
644
|
+
// Remove or comment out these lines in toLatex function
|
|
644
645
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
645
|
-
result = result.replace(/≤/g, "\\leq");
|
|
646
|
-
result = result.replace(/≥/g, "\\geq");
|
|
647
|
-
result = result.replace(/≠/g, "\\neq");
|
|
648
|
-
result = result.replace(/≈/g, "\\approx");
|
|
649
|
-
result = result.replace(/π/g, "\\pi");
|
|
650
|
-
result = result.replace(/α/g, "\\alpha");
|
|
651
|
-
result = result.replace(/β/g, "\\beta");
|
|
652
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
646
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
647
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
648
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
649
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
650
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
651
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
652
|
+
// result = result.replace(/β/g, "\\beta");
|
|
653
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
653
654
|
|
|
654
655
|
return result;
|
|
655
656
|
}
|
|
@@ -772,9 +773,25 @@ function parseElementMs(node) {
|
|
|
772
773
|
|
|
773
774
|
// Math Text
|
|
774
775
|
function parseElementMtext(node) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
776
|
+
let content = NodeTool.getNodeText(node)
|
|
777
|
+
// Handle operators and spacing only
|
|
778
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
779
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
780
|
+
.trim();
|
|
781
|
+
|
|
782
|
+
// Handle units with proper \mathrm formatting
|
|
783
|
+
if (content.includes('(') && content.includes(')')) {
|
|
784
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
785
|
+
content = parts.map(part => {
|
|
786
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
787
|
+
// Keep original characters in units
|
|
788
|
+
return `\\mathrm{${part}}`;
|
|
789
|
+
}
|
|
790
|
+
return part;
|
|
791
|
+
}).join('');
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return content;
|
|
778
795
|
}
|
|
779
796
|
|
|
780
797
|
// Math glyph (image)
|
|
@@ -647,15 +647,16 @@
|
|
|
647
647
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
648
648
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
649
649
|
|
|
650
|
+
// Remove or comment out these lines in toLatex function
|
|
650
651
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
651
|
-
result = result.replace(/≤/g, "\\leq");
|
|
652
|
-
result = result.replace(/≥/g, "\\geq");
|
|
653
|
-
result = result.replace(/≠/g, "\\neq");
|
|
654
|
-
result = result.replace(/≈/g, "\\approx");
|
|
655
|
-
result = result.replace(/π/g, "\\pi");
|
|
656
|
-
result = result.replace(/α/g, "\\alpha");
|
|
657
|
-
result = result.replace(/β/g, "\\beta");
|
|
658
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
652
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
653
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
654
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
655
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
656
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
657
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
658
|
+
// result = result.replace(/β/g, "\\beta");
|
|
659
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
659
660
|
|
|
660
661
|
return result;
|
|
661
662
|
}
|
|
@@ -778,9 +779,25 @@
|
|
|
778
779
|
|
|
779
780
|
// Math Text
|
|
780
781
|
function parseElementMtext(node) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
782
|
+
let content = NodeTool.getNodeText(node)
|
|
783
|
+
// Handle operators and spacing only
|
|
784
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
785
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
786
|
+
.trim();
|
|
787
|
+
|
|
788
|
+
// Handle units with proper \mathrm formatting
|
|
789
|
+
if (content.includes('(') && content.includes(')')) {
|
|
790
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
791
|
+
content = parts.map(part => {
|
|
792
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
793
|
+
// Keep original characters in units
|
|
794
|
+
return `\\mathrm{${part}}`;
|
|
795
|
+
}
|
|
796
|
+
return part;
|
|
797
|
+
}).join('');
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return content;
|
|
784
801
|
}
|
|
785
802
|
|
|
786
803
|
// Math glyph (image)
|
package/lib/mathml2latex.cjs.js
CHANGED
|
@@ -643,15 +643,16 @@ function toLatex(result) {
|
|
|
643
643
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
644
644
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
645
645
|
|
|
646
|
+
// Remove or comment out these lines in toLatex function
|
|
646
647
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
647
|
-
result = result.replace(/≤/g, "\\leq");
|
|
648
|
-
result = result.replace(/≥/g, "\\geq");
|
|
649
|
-
result = result.replace(/≠/g, "\\neq");
|
|
650
|
-
result = result.replace(/≈/g, "\\approx");
|
|
651
|
-
result = result.replace(/π/g, "\\pi");
|
|
652
|
-
result = result.replace(/α/g, "\\alpha");
|
|
653
|
-
result = result.replace(/β/g, "\\beta");
|
|
654
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
648
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
649
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
650
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
651
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
652
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
653
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
654
|
+
// result = result.replace(/β/g, "\\beta");
|
|
655
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
655
656
|
|
|
656
657
|
return result;
|
|
657
658
|
}
|
|
@@ -774,9 +775,25 @@ function parseElementMs(node) {
|
|
|
774
775
|
|
|
775
776
|
// Math Text
|
|
776
777
|
function parseElementMtext(node) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
let content = NodeTool.getNodeText(node)
|
|
779
|
+
// Handle operators and spacing only
|
|
780
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
781
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
782
|
+
.trim();
|
|
783
|
+
|
|
784
|
+
// Handle units with proper \mathrm formatting
|
|
785
|
+
if (content.includes('(') && content.includes(')')) {
|
|
786
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
787
|
+
content = parts.map(part => {
|
|
788
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
789
|
+
// Keep original characters in units
|
|
790
|
+
return `\\mathrm{${part}}`;
|
|
791
|
+
}
|
|
792
|
+
return part;
|
|
793
|
+
}).join('');
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return content;
|
|
780
797
|
}
|
|
781
798
|
|
|
782
799
|
// Math glyph (image)
|
package/lib/mathml2latex.es.js
CHANGED
|
@@ -641,15 +641,16 @@ function toLatex(result) {
|
|
|
641
641
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
642
642
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
643
643
|
|
|
644
|
+
// Remove or comment out these lines in toLatex function
|
|
644
645
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
645
|
-
result = result.replace(/≤/g, "\\leq");
|
|
646
|
-
result = result.replace(/≥/g, "\\geq");
|
|
647
|
-
result = result.replace(/≠/g, "\\neq");
|
|
648
|
-
result = result.replace(/≈/g, "\\approx");
|
|
649
|
-
result = result.replace(/π/g, "\\pi");
|
|
650
|
-
result = result.replace(/α/g, "\\alpha");
|
|
651
|
-
result = result.replace(/β/g, "\\beta");
|
|
652
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
646
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
647
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
648
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
649
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
650
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
651
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
652
|
+
// result = result.replace(/β/g, "\\beta");
|
|
653
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
653
654
|
|
|
654
655
|
return result;
|
|
655
656
|
}
|
|
@@ -772,9 +773,25 @@ function parseElementMs(node) {
|
|
|
772
773
|
|
|
773
774
|
// Math Text
|
|
774
775
|
function parseElementMtext(node) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
776
|
+
let content = NodeTool.getNodeText(node)
|
|
777
|
+
// Handle operators and spacing only
|
|
778
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
779
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
780
|
+
.trim();
|
|
781
|
+
|
|
782
|
+
// Handle units with proper \mathrm formatting
|
|
783
|
+
if (content.includes('(') && content.includes(')')) {
|
|
784
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
785
|
+
content = parts.map(part => {
|
|
786
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
787
|
+
// Keep original characters in units
|
|
788
|
+
return `\\mathrm{${part}}`;
|
|
789
|
+
}
|
|
790
|
+
return part;
|
|
791
|
+
}).join('');
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return content;
|
|
778
795
|
}
|
|
779
796
|
|
|
780
797
|
// Math glyph (image)
|
package/lib/mathml2latex.umd.js
CHANGED
|
@@ -647,15 +647,16 @@
|
|
|
647
647
|
result = result.replace(/([A-Za-z0-9]+)_([0-9])\^\{\\rightarrow\}/g, "\\overrightarrow{$1_$2}");
|
|
648
648
|
result = result.replace(/(\([^()]+\))\^\{\\rightarrow\}/g, "\\overrightarrow{$1}");
|
|
649
649
|
|
|
650
|
+
// Remove or comment out these lines in toLatex function
|
|
650
651
|
// Thêm xử lý các ký hiệu toán học phổ biến
|
|
651
|
-
result = result.replace(/≤/g, "\\leq");
|
|
652
|
-
result = result.replace(/≥/g, "\\geq");
|
|
653
|
-
result = result.replace(/≠/g, "\\neq");
|
|
654
|
-
result = result.replace(/≈/g, "\\approx");
|
|
655
|
-
result = result.replace(/π/g, "\\pi");
|
|
656
|
-
result = result.replace(/α/g, "\\alpha");
|
|
657
|
-
result = result.replace(/β/g, "\\beta");
|
|
658
|
-
result = result.replace(/γ/g, "\\gamma");
|
|
652
|
+
// result = result.replace(/≤/g, "\\leq");
|
|
653
|
+
// result = result.replace(/≥/g, "\\geq");
|
|
654
|
+
// result = result.replace(/≠/g, "\\neq");
|
|
655
|
+
// result = result.replace(/≈/g, "\\approx");
|
|
656
|
+
// result = result.replace(/π/g, "\\pi"); // Comment out or remove this line
|
|
657
|
+
// result = result.replace(/α/g, "\\alpha");
|
|
658
|
+
// result = result.replace(/β/g, "\\beta");
|
|
659
|
+
// result = result.replace(/γ/g, "\\gamma");
|
|
659
660
|
|
|
660
661
|
return result;
|
|
661
662
|
}
|
|
@@ -778,9 +779,25 @@
|
|
|
778
779
|
|
|
779
780
|
// Math Text
|
|
780
781
|
function parseElementMtext(node) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
782
|
+
let content = NodeTool.getNodeText(node)
|
|
783
|
+
// Handle operators and spacing only
|
|
784
|
+
.replace(/\s*=\s*/g, ' = ')
|
|
785
|
+
.replace(/\s*\.\s*/g, ' \\cdot ')
|
|
786
|
+
.trim();
|
|
787
|
+
|
|
788
|
+
// Handle units with proper \mathrm formatting
|
|
789
|
+
if (content.includes('(') && content.includes(')')) {
|
|
790
|
+
const parts = content.split(/(\([^)]+\))/);
|
|
791
|
+
content = parts.map(part => {
|
|
792
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
793
|
+
// Keep original characters in units
|
|
794
|
+
return `\\mathrm{${part}}`;
|
|
795
|
+
}
|
|
796
|
+
return part;
|
|
797
|
+
}).join('');
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return content;
|
|
784
801
|
}
|
|
785
802
|
|
|
786
803
|
// Math glyph (image)
|