dwml-ts 0.4.2 → 0.5.1
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 +13 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ export declare function localName(tagName: string): string;
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Convert an already-parsed `oMath` (or oMath-like) node to bare LaTeX.
|
|
23
|
-
*
|
|
23
|
+
* Unwraps `oMathPara` / `a14:m` so display math is not flattened to concatenated
|
|
24
|
+
* `m:t` text (`3/8` → `38`). Never throws on unknown constructs.
|
|
24
25
|
*/
|
|
25
26
|
export declare function ommlNodeToLatex(node: TNode, options?: OmmlToLatexOptions): string;
|
|
26
27
|
|
package/dist/index.js
CHANGED
|
@@ -2063,7 +2063,9 @@ const DIRECT_TAGS = new Set([
|
|
|
2063
2063
|
'num',
|
|
2064
2064
|
'den',
|
|
2065
2065
|
'deg',
|
|
2066
|
-
'e'
|
|
2066
|
+
'e',
|
|
2067
|
+
'oMath',
|
|
2068
|
+
'oMathPara'
|
|
2067
2069
|
]);
|
|
2068
2070
|
class Converter {
|
|
2069
2071
|
convert(node) {
|
|
@@ -2387,7 +2389,17 @@ class Converter {
|
|
|
2387
2389
|
}
|
|
2388
2390
|
const SUB_TEMPLATE = '_{{{0}}}';
|
|
2389
2391
|
const SUP_TEMPLATE = '^{{{0}}}';
|
|
2392
|
+
function findLocal(node, name, acc = []) {
|
|
2393
|
+
if (localName(node.tagName) === name) acc.push(node);
|
|
2394
|
+
for (const child of node.children)if ('string' != typeof child) findLocal(child, name, acc);
|
|
2395
|
+
return acc;
|
|
2396
|
+
}
|
|
2390
2397
|
function ommlNodeToLatex(node, options = {}) {
|
|
2398
|
+
const name = localName(node.tagName);
|
|
2399
|
+
if ('oMathPara' === name || 'm' === name) {
|
|
2400
|
+
const found = findLocal(node, 'oMath');
|
|
2401
|
+
if (found.length) return found.map((omath)=>new Converter(options).convert(omath)).join('').trim();
|
|
2402
|
+
}
|
|
2391
2403
|
return new Converter(options).convert(node);
|
|
2392
2404
|
}
|
|
2393
2405
|
function findAll(nodes, name, acc = []) {
|