Project Files
scripts / test-roundtrip.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
// Manual round-trip test — not shipped, run via:
// npx tsx test-roundtrip.ts
// or compile + run.
const fs = __importStar(require("node:fs/promises"));
const os = __importStar(require("node:os"));
const path = __importStar(require("node:path"));
const docxWrite_1 = require("./src/docxWrite");
const docxRead_1 = require("./src/docxRead");
const sample = `# Titre principal
Un paragraphe avec du **gras**, de l'*italique* et un peu de \`code\`.
## Section 2
- Premier point
- Deuxième point avec **emphase**
- Troisième point
1. Étape un
2. Étape deux
> Une citation à conserver
> sur deux lignes.
Voici un [lien externe](https://example.com).
\`\`\`
ligne de code 1
ligne de code 2
\`\`\`
`;
async function main() {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "docx-rt-"));
const outPath = path.join(dir, "sample.docx");
console.log("→ writing", outPath);
const w = await (0, docxWrite_1.writeDocx)(outPath, sample, {
fontFamily: "Calibri",
fontSizePt: 11,
pageMargin: "normal",
preserveListStyles: true,
title: "Round-trip test",
});
console.log(" wrote", w.bytes, "bytes,", w.paragraphs, "paragraphs");
console.log(" warnings:", w.warnings);
const r = await (0, docxRead_1.readDocx)(outPath, { preserveStyles: true, includeMetadata: true });
console.log("\n→ markdown back:\n");
console.log(r.markdown);
console.log("\n→ metadata:", r.metadata);
console.log("→ warnings:", r.warnings);
}
main().catch((e) => {
console.error(e);
process.exit(1);
});
//# sourceMappingURL=test-roundtrip.js.map