dwml-ts 0.5.0 → 0.5.2
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/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
38
38
|
unicodeToLatex: ()=>unicodeToLatex
|
|
39
39
|
});
|
|
40
40
|
const txml_namespaceObject = require("txml/txml");
|
|
41
|
+
const external_entities_namespaceObject = require("entities");
|
|
41
42
|
const UNI2LATEX = {
|
|
42
43
|
34: "''",
|
|
43
44
|
35: "\\#",
|
|
@@ -1985,7 +1986,7 @@ function isElement(node) {
|
|
|
1985
1986
|
}
|
|
1986
1987
|
function textContent(node) {
|
|
1987
1988
|
let out = '';
|
|
1988
|
-
for (const child of node.children)out += 'string' == typeof child ? child : textContent(child);
|
|
1989
|
+
for (const child of node.children)out += 'string' == typeof child ? (0, external_entities_namespaceObject.decodeXML)(child) : textContent(child);
|
|
1989
1990
|
return out;
|
|
1990
1991
|
}
|
|
1991
1992
|
function pyFormat(template, positional = [], named = {}) {
|
|
@@ -2102,7 +2103,9 @@ const DIRECT_TAGS = new Set([
|
|
|
2102
2103
|
'num',
|
|
2103
2104
|
'den',
|
|
2104
2105
|
'deg',
|
|
2105
|
-
'e'
|
|
2106
|
+
'e',
|
|
2107
|
+
'oMath',
|
|
2108
|
+
'oMathPara'
|
|
2106
2109
|
]);
|
|
2107
2110
|
class Converter {
|
|
2108
2111
|
convert(node) {
|
|
@@ -2426,7 +2429,17 @@ class Converter {
|
|
|
2426
2429
|
}
|
|
2427
2430
|
const SUB_TEMPLATE = '_{{{0}}}';
|
|
2428
2431
|
const SUP_TEMPLATE = '^{{{0}}}';
|
|
2432
|
+
function findLocal(node, name, acc = []) {
|
|
2433
|
+
if (localName(node.tagName) === name) acc.push(node);
|
|
2434
|
+
for (const child of node.children)if ('string' != typeof child) findLocal(child, name, acc);
|
|
2435
|
+
return acc;
|
|
2436
|
+
}
|
|
2429
2437
|
function ommlNodeToLatex(node, options = {}) {
|
|
2438
|
+
const name = localName(node.tagName);
|
|
2439
|
+
if ('oMathPara' === name || 'm' === name) {
|
|
2440
|
+
const found = findLocal(node, 'oMath');
|
|
2441
|
+
if (found.length) return found.map((omath)=>new Converter(options).convert(omath)).join('').trim();
|
|
2442
|
+
}
|
|
2430
2443
|
return new Converter(options).convert(node);
|
|
2431
2444
|
}
|
|
2432
2445
|
function findAll(nodes, name, acc = []) {
|