ooxml.js 1.3.0 → 1.3.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 +12 -1
- package/dist/index.js +12 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -612,6 +612,17 @@ function readRow(row) {
|
|
|
612
612
|
function readTable$1(table) {
|
|
613
613
|
return { rows: childrenWithTag(table, "w:tr").map(readRow) };
|
|
614
614
|
}
|
|
615
|
+
function* walkExcludingTables(nodes) {
|
|
616
|
+
for (const node of nodes) {
|
|
617
|
+
yield node;
|
|
618
|
+
if (node.type === "element" && node.tag !== "w:tbl") yield* walkExcludingTables(node.children);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
function bodyParagraphElements(nodes) {
|
|
622
|
+
const out = [];
|
|
623
|
+
for (const node of walkExcludingTables(nodes)) if (node.type === "element" && node.tag === "w:p") out.push(node);
|
|
624
|
+
return out;
|
|
625
|
+
}
|
|
615
626
|
function readHyperlink(hyperlink, rels) {
|
|
616
627
|
const text = elementsWithTag(hyperlink.children, "w:t").map(textContent).join("");
|
|
617
628
|
const rid = attr(hyperlink, "r:id");
|
|
@@ -664,7 +675,7 @@ function readDocx(pkg) {
|
|
|
664
675
|
if (part.kind !== "xml") throw new Error("readDocx: word/document.xml is not an XML part");
|
|
665
676
|
const rels = resolveRelationships(pkg, "word/document.xml");
|
|
666
677
|
return {
|
|
667
|
-
paragraphs:
|
|
678
|
+
paragraphs: bodyParagraphElements(part.nodes).map(readParagraph),
|
|
668
679
|
tables: elementsWithTag(part.nodes, "w:tbl").map(readTable$1),
|
|
669
680
|
hyperlinks: elementsWithTag(part.nodes, "w:hyperlink").map((h) => readHyperlink(h, rels)),
|
|
670
681
|
comments: readComments(pkg),
|
package/dist/index.js
CHANGED
|
@@ -611,6 +611,17 @@ function readRow(row) {
|
|
|
611
611
|
function readTable$1(table) {
|
|
612
612
|
return { rows: childrenWithTag(table, "w:tr").map(readRow) };
|
|
613
613
|
}
|
|
614
|
+
function* walkExcludingTables(nodes) {
|
|
615
|
+
for (const node of nodes) {
|
|
616
|
+
yield node;
|
|
617
|
+
if (node.type === "element" && node.tag !== "w:tbl") yield* walkExcludingTables(node.children);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function bodyParagraphElements(nodes) {
|
|
621
|
+
const out = [];
|
|
622
|
+
for (const node of walkExcludingTables(nodes)) if (node.type === "element" && node.tag === "w:p") out.push(node);
|
|
623
|
+
return out;
|
|
624
|
+
}
|
|
614
625
|
function readHyperlink(hyperlink, rels) {
|
|
615
626
|
const text = elementsWithTag(hyperlink.children, "w:t").map(textContent).join("");
|
|
616
627
|
const rid = attr(hyperlink, "r:id");
|
|
@@ -663,7 +674,7 @@ function readDocx(pkg) {
|
|
|
663
674
|
if (part.kind !== "xml") throw new Error("readDocx: word/document.xml is not an XML part");
|
|
664
675
|
const rels = resolveRelationships(pkg, "word/document.xml");
|
|
665
676
|
return {
|
|
666
|
-
paragraphs:
|
|
677
|
+
paragraphs: bodyParagraphElements(part.nodes).map(readParagraph),
|
|
667
678
|
tables: elementsWithTag(part.nodes, "w:tbl").map(readTable$1),
|
|
668
679
|
hyperlinks: elementsWithTag(part.nodes, "w:hyperlink").map((h) => readHyperlink(h, rels)),
|
|
669
680
|
comments: readComments(pkg),
|
package/package.json
CHANGED