Adding mammoth library tests for docx conversion

This commit is contained in:
Julio Ruiz 2026-02-27 20:22:59 -05:00
parent c1b62b0a97
commit 2acad0c6c8
13 changed files with 2890 additions and 0 deletions

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a:clrMap xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>

View File

@ -0,0 +1,9 @@
<xml xmlns:o="urn:schemas-microsoft-com:office:office">
<o:MainFile HRef="../2026-02-26-3-DRAFT-JBP-JUEVES-adopcion_hijo_reino.htm"/>
<o:File HRef="item0001.xml"/>
<o:File HRef="props002.xml"/>
<o:File HRef="themedata.thmx"/>
<o:File HRef="colorschememapping.xml"/>
<o:File HRef="editdata.mso"/>
<o:File HRef="filelist.xml"/>
</xml>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><go:gDocsCustomXmlDataStorage xmlns:go="http://customooxmlschemas.google.com/" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" uri="GoogleDocsCustomDataVersion2"><go:docsCustomData xmlns:go="http://customooxmlschemas.google.com/" roundtripDataSignature="AMtx7miOdRLYb2/SolaLBW577aemQpSF1w==">CgMxLjA4AHIhMUQ3OE5zTEY1SGlkclpXZGVKNWVYYlhqZU1Hd3RiVF9u</go:docsCustomData></go:gDocsCustomXmlDataStorage>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ds:datastoreItem ds:itemID="{11111111-1234-1234-1234-123412341234}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml"><ds:schemaRefs><ds:schemaRef ds:uri="http://customooxmlschemas.google.com/"/><ds:schemaRef ds:uri="http://schemas.openxmlformats.org/officeDocument/2006/relationships"/></ds:schemaRefs></ds:datastoreItem>

File diff suppressed because it is too large Load Diff

42
mammoth/index.js Normal file
View File

@ -0,0 +1,42 @@
const fs = require('fs');
const path = require('path');
var mammoth = require("mammoth");
var options = {
styleMap: [
"p.JBPCar => p.jbp",
"r.JBPCar => span.jbp",
"p.JBPNegroCar => p.jbp.black",
"r.JBPNegroCar => span.jbp.black",
"p.CitaBiblica => p.bible-quote",
"p.CitaBiblicaCar => p.bible-quote",
"r.CitaBiblicaCar => span.bible-quote",
"p.JBPAzul => p.jbp.blue",
"p.JBPAzulCar => p.jbp.blue",
"r.JBPAzulCar => span.jbp.blue",
"p.WMBMorado => p.wmb.purple"
]
};
mammoth.convertToHtml({path: "./testdocstyles.docx"}, options)
.then(function(result){
var html = result.value; // The generated HTML
var messages = result.messages; // Any messages, such as warnings during conversion
console.log( messages )
writeFile( html )
})
.catch(function(error) {
console.error(error);
});
function writeFile(data) {
fs.writeFile(`./test.html`, data, (err) => {
if (err) {
console.error("Error writing file:", err);
return;
}
console.log("File has been written successfully!");
});
}

241
mammoth/package-lock.json generated Normal file
View File

@ -0,0 +1,241 @@
{
"name": "mammoth",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"mammoth": "^1.11.0"
}
},
"node_modules/@xmldom/xmldom": {
"version": "0.8.11",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.11.tgz",
"integrity": "sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/bluebird": {
"version": "3.4.7",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz",
"integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==",
"license": "MIT"
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
"license": "MIT"
},
"node_modules/dingbat-to-unicode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dingbat-to-unicode/-/dingbat-to-unicode-1.0.1.tgz",
"integrity": "sha512-98l0sW87ZT58pU4i61wa2OHwxbiYSbuxsCBozaVnYX2iCnr3bLM3fIes1/ej7h1YdOKuKt/MLs706TVnALA65w==",
"license": "BSD-2-Clause"
},
"node_modules/duck": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz",
"integrity": "sha512-wkctla1O6VfP89gQ+J/yDesM0S7B7XLXjKGzXxMDVFg7uEn706niAtyYovKbyq1oT9YwDcly721/iUWoc8MVRg==",
"license": "BSD",
"dependencies": {
"underscore": "^1.13.1"
}
},
"node_modules/immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
"license": "MIT"
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"license": "MIT"
},
"node_modules/jszip": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
"license": "(MIT OR GPL-3.0-or-later)",
"dependencies": {
"lie": "~3.3.0",
"pako": "~1.0.2",
"readable-stream": "~2.3.6",
"setimmediate": "^1.0.5"
}
},
"node_modules/lie": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
"license": "MIT",
"dependencies": {
"immediate": "~3.0.5"
}
},
"node_modules/lop": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/lop/-/lop-0.4.2.tgz",
"integrity": "sha512-RefILVDQ4DKoRZsJ4Pj22TxE3omDO47yFpkIBoDKzkqPRISs5U1cnAdg/5583YPkWPaLIYHOKRMQSvjFsO26cw==",
"license": "BSD-2-Clause",
"dependencies": {
"duck": "^0.1.12",
"option": "~0.2.1",
"underscore": "^1.13.1"
}
},
"node_modules/mammoth": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/mammoth/-/mammoth-1.11.0.tgz",
"integrity": "sha512-BcEqqY/BOwIcI1iR5tqyVlqc3KIaMRa4egSoK83YAVrBf6+yqdAAbtUcFDCWX8Zef8/fgNZ6rl4VUv+vVX8ddQ==",
"license": "BSD-2-Clause",
"dependencies": {
"@xmldom/xmldom": "^0.8.6",
"argparse": "~1.0.3",
"base64-js": "^1.5.1",
"bluebird": "~3.4.0",
"dingbat-to-unicode": "^1.0.1",
"jszip": "^3.7.1",
"lop": "^0.4.2",
"path-is-absolute": "^1.0.0",
"underscore": "^1.13.1",
"xmlbuilder": "^10.0.0"
},
"bin": {
"mammoth": "bin/mammoth"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/option": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/option/-/option-0.2.4.tgz",
"integrity": "sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==",
"license": "BSD-2-Clause"
},
"node_modules/pako": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"license": "(MIT AND Zlib)"
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"license": "MIT"
},
"node_modules/readable-stream": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
"license": "MIT"
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"license": "BSD-3-Clause"
},
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.1.0"
}
},
"node_modules/underscore": {
"version": "1.13.8",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.8.tgz",
"integrity": "sha512-DXtD3ZtEQzc7M8m4cXotyHR+FAS18C64asBYY5vqZexfYryNNnDc02W4hKg3rdQuqOYas1jkseX0+nZXjTXnvQ==",
"license": "MIT"
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
"node_modules/xmlbuilder": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-10.1.1.tgz",
"integrity": "sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==",
"license": "MIT",
"engines": {
"node": ">=4.0"
}
}
}
}

5
mammoth/package.json Normal file
View File

@ -0,0 +1,5 @@
{
"dependencies": {
"mammoth": "^1.11.0"
}
}

30
mammoth/test.html Normal file
View File

@ -0,0 +1,30 @@
<html>
<head>
<style>
.bible-quote {
font-family: 'Times New Roman', Times, serif;
font-style: oblique;
}
.jbp {
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
}
.wmb {
font-family: 'Times New Roman', Times, serif;
font-style: oblique;
}
.black {
color : black;
}
.blue {
color : #0070C0;
}
.purple {
color : #7030A0;
}
</style>
</head>
<body>
<p><strong>San Mateo 17:10</strong></p><p class="bible-quote">10 Entonces sus discípulos le preguntaron, diciendo: ¿Por qué, pues, dicen los escribas que es necesario que Elías venga primero?</p><p>[JBP] Porque Malaquías nos habló, en el capítulo 3, de ese precursor que iba a venir antes de la Venida del Ángel del Pacto. El Ángel del Pacto, el cual guio al pueblo hebreo, lo sacó por mano de Moisés de la esclavitud de Egipto, y los libertó; y luego los introdujo, por medio de Josué, a la tierra prometida que él les había prometido; y ese Ángel del Pacto se hizo carne.</p><p>En San Juan, capítulo 1, vemos esa Escritura donde nos dice que ese Verbo —Aquel que era con Dios, y era Dios— se hizo carne; y dice: “Y habitó entre nosotros” [San Lucas 1:14]; y fue llamado por el nombre Jesús.</p><p>Ahora, Él aquí, en el verso 11, respondió esa pregunta que le hacen discípulos; y Él les dice:</p><p><strong>San Mateo 17:11</strong></p><p><span class="bible-quote">11 Respondiendo Jesús, les dijo: A la verdad, Elías viene primero</span><em> </em><span class="jbp blue">([JBP] ahora habla de un Elías que iba a venir antes de Su Segunda Venida</span><span class="bible-quote">), y restaurará todas las cosas.</span></p><p class="jbp blue">[JBP] Y ya vino y Dios se lo llevó: fue el reverendo William Marrion Branham.</p><p><span class="bible-quote">12 Mas os digo que Elías ya vino</span><em> </em><span class="jbp blue">([JBP] y ya ahí él se refiere a Juan el Bautista)</span><span class="bible-quote">, y no le conocieron, sino que hicieron con él todo lo que quisieron; así también el Hijo del Hombre padecerá de ellos.</span></p><p><span class="jbp">[Dr. José B. Pérez] Ahora, hablándonos en este mensaje, él nos dice</span> [<strong>“NUESTRA POSICIÓN EN CRISTO”</strong>]:</p><p>[<strong>55-0116A</strong> “Nuestra posición en Cristo”, (párrs. 41-47 en inglés)] [Estudio Bíblico #291, 2023/mar/19 (domingo), págs. 39-41, 45-46 (f), págs. 135-137, 141-142 (T3)]</p><p class="wmb purple">41 En Gálatas, capítulo 4, del verso 1 al 5, tenemos un cuadro hermoso de eso, cómo estuvimos nosotros bajo tutores.Cuando este niño nacía se convertía en hijo, al momento de nacer en la familia. ¿Lo entienden? Ahora, había un tutor sobre este muchacho, para educarlo y criarlo. Él no era más que un siervo, dice la carta a los Gálatas <span class="jbp black">([JBP] que es la Escritura que leímos)</span>, hasta que llegaba a cierta edad, a cierto límite de tiempo que era establecido. Este tutor tenía que llevarle el reporte al padre: “Tu hijo va progresando bien”, o cualquier cosa. Es allí donde… No es que esté en desacuerdo, mi querido hermano, pero tómelo como de alguien que lo ama.42 Fue allí donde los pentecostales fallaron. Si el Espíritu Santo, tal vez, no queriendo dárselos entonces. Fíjense, cuando usted nace del Espíritu Santo, usted dice: “Este sí que es, hermano”.Usted ya era un hijo. Lo era tanto como siempre lo fue, porque nació en la familia. Pero sin embargo, el Tutor, que es el Espíritu Santo, ha observado la Iglesia mientras va madurando.</p>
</body>
</html>

BIN
mammoth/testdocstyles.docx Normal file

Binary file not shown.