@ryangarber/markitdown-ts 0.1.4 → 0.1.5
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/README.md +1 -0
- package/dist/cli.mjs +101 -22
- package/dist/index.cjs +11506 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -21
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/markitdown.ts"],"mappings":";KAAY;EACV;EACA;;EAEA;;;;;;;;KASU,aAAa,aAAa,kBAAkB,kBAAkB;KAE9D;;EAEV;;EAEA;;EAEA,eAAe;;EAEf;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,qBAAqB;EACrB;;UAGe;EACf,QAAQ,QAAQ,YAAY,SAAS,mBAAmB,QAAQ;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/markitdown.ts"],"mappings":";KAAY;EACV;EACA;;EAEA;;;;;;;;KASU,aAAa,aAAa,kBAAkB,kBAAkB;KAE9D;;EAEV;;EAEA;;EAEA,eAAe;;EAEf;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,qBAAqB;EACrB;;UAGe;EACf,QAAQ,QAAQ,YAAY,SAAS,mBAAmB,QAAQ;;;;KClBtD,mBAAmB,aAAa,WAAW;cAE1C;mBACM;EAEjB;;EAgBM,QACJ,QAAQ,kBACR,UAAS,mBACR,QAAQ;;;;EA+BL,cACJ,QAAQ,YACR,SAAS;IAAqB;MAC7B,QAAQ;UAIG;UAoBA;UA+BA;UAuCN;UASA"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/markitdown.ts"],"mappings":";KAAY;EACV;EACA;;EAEA;;;;;;;;KASU,aAAa,aAAa,kBAAkB,kBAAkB;KAE9D;;EAEV;;EAEA;;EAEA,eAAe;;EAEf;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,qBAAqB;EACrB;;UAGe;EACf,QAAQ,QAAQ,YAAY,SAAS,mBAAmB,QAAQ;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/markitdown.ts"],"mappings":";KAAY;EACV;EACA;;EAEA;;;;;;;;KASU,aAAa,aAAa,kBAAkB,kBAAkB;KAE9D;;EAEV;;EAEA;;EAEA,eAAe;;EAEf;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,qBAAqB;EACrB;;UAGe;EACf,QAAQ,QAAQ,YAAY,SAAS,mBAAmB,QAAQ;;;;KClBtD,mBAAmB,aAAa,WAAW;cAE1C;mBACM;EAEjB;;EAgBM,QACJ,QAAQ,kBACR,UAAS,mBACR,QAAQ;;;;EA+BL,cACJ,QAAQ,YACR,SAAS;IAAqB;MAC7B,QAAQ;UAIG;UAoBA;UA+BA;UAuCN;UASA"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import TurndownService from "turndown";
|
|
|
3
3
|
import { parseHTML } from "linkedom";
|
|
4
4
|
import mammoth from "mammoth";
|
|
5
5
|
import { extractText, getDocumentProxy, getMeta } from "unpdf";
|
|
6
|
-
import
|
|
7
|
-
import { DOMParser } from "@xmldom/xmldom";
|
|
6
|
+
import { pptxToHtml } from "@jvmr/pptx-to-html";
|
|
7
|
+
import { DOMParser, Document, Element, Node } from "@xmldom/xmldom";
|
|
8
|
+
import readExcelFile from "read-excel-file/universal";
|
|
8
9
|
import { unzipSync } from "fflate";
|
|
9
10
|
//#region src/bytes.ts
|
|
10
11
|
async function toUint8Array(source) {
|
|
@@ -215,6 +216,7 @@ const MIME_EXTENSIONS = {
|
|
|
215
216
|
"application/zip": ".zip",
|
|
216
217
|
"application/rss+xml": ".rss",
|
|
217
218
|
"application/x-pdf": ".pdf",
|
|
219
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
|
|
218
220
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
|
|
219
221
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
|
|
220
222
|
"application/xml": ".xml",
|
|
@@ -260,6 +262,85 @@ var PlainTextConverter = class {
|
|
|
260
262
|
}
|
|
261
263
|
};
|
|
262
264
|
//#endregion
|
|
265
|
+
//#region src/converters/pptx.ts
|
|
266
|
+
var PptxConverter = class extends HtmlConverter {
|
|
267
|
+
async convert(source, options) {
|
|
268
|
+
if (options.file_extension?.toLowerCase() !== ".pptx") return null;
|
|
269
|
+
const slides = await pptxToHtml(toArrayBuffer(source), { domParserFactory: createPptxDomParser });
|
|
270
|
+
const sections = [];
|
|
271
|
+
for (const [index, html] of slides.entries()) {
|
|
272
|
+
const result = await this.convertHtml(`<html><body>${html}</body></html>`);
|
|
273
|
+
sections.push(`<!-- Slide number: ${index + 1} -->\n${result?.markdown.trim() ?? ""}`);
|
|
274
|
+
}
|
|
275
|
+
const markdown = sections.join("\n\n");
|
|
276
|
+
return {
|
|
277
|
+
title: null,
|
|
278
|
+
markdown,
|
|
279
|
+
text_content: markdown
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
function createPptxDomParser() {
|
|
284
|
+
if (typeof globalThis.DOMParser === "function") return new globalThis.DOMParser();
|
|
285
|
+
patchXmlDom();
|
|
286
|
+
return new DOMParser();
|
|
287
|
+
}
|
|
288
|
+
let xmlDomPatched = false;
|
|
289
|
+
function patchXmlDom() {
|
|
290
|
+
if (xmlDomPatched) return;
|
|
291
|
+
xmlDomPatched = true;
|
|
292
|
+
defineMethod(Element.prototype, "querySelector", querySelector);
|
|
293
|
+
defineMethod(Element.prototype, "querySelectorAll", querySelectorAll);
|
|
294
|
+
defineMethod(Document.prototype, "querySelector", querySelector);
|
|
295
|
+
defineMethod(Document.prototype, "querySelectorAll", querySelectorAll);
|
|
296
|
+
defineGetter(Element.prototype, "children", function() {
|
|
297
|
+
return [...this.childNodes].filter((node) => node.nodeType === 1);
|
|
298
|
+
});
|
|
299
|
+
defineGetter(Node.prototype, "parentElement", function() {
|
|
300
|
+
const parent = this.parentNode;
|
|
301
|
+
return parent?.nodeType === 1 ? parent : null;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function querySelector(selector) {
|
|
305
|
+
for (const group of selector.split(",")) {
|
|
306
|
+
const match = queryByPath(this, group.trim());
|
|
307
|
+
if (match) return match;
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
function querySelectorAll() {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
function queryByPath(root, selector) {
|
|
315
|
+
const tokens = selector.split(/\s+/).filter(Boolean);
|
|
316
|
+
let current = [root];
|
|
317
|
+
for (const token of tokens) {
|
|
318
|
+
const localName = selectorLocalName(token);
|
|
319
|
+
const next = [];
|
|
320
|
+
for (const node of current) next.push(...Array.from(node.getElementsByTagNameNS("*", localName)));
|
|
321
|
+
current = next;
|
|
322
|
+
}
|
|
323
|
+
return current[0] ?? null;
|
|
324
|
+
}
|
|
325
|
+
function selectorLocalName(token) {
|
|
326
|
+
if (token.includes("|")) return token.slice(token.lastIndexOf("|") + 1);
|
|
327
|
+
return token.replace(/\\:/g, ":").split(":").pop() ?? token;
|
|
328
|
+
}
|
|
329
|
+
function defineMethod(target, name, value) {
|
|
330
|
+
Object.defineProperty(target, name, {
|
|
331
|
+
configurable: true,
|
|
332
|
+
writable: true,
|
|
333
|
+
value
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function defineGetter(target, name, get) {
|
|
337
|
+
if (Object.getOwnPropertyDescriptor(target, name)) return;
|
|
338
|
+
Object.defineProperty(target, name, {
|
|
339
|
+
configurable: true,
|
|
340
|
+
get
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
263
344
|
//#region src/converters/wikipedia.ts
|
|
264
345
|
const WIKIPEDIA_URL = /^https?:\/\/[a-z]{2,3}\.wikipedia\.org\//i;
|
|
265
346
|
var WikipediaConverter = class {
|
|
@@ -282,41 +363,38 @@ var WikipediaConverter = class {
|
|
|
282
363
|
};
|
|
283
364
|
//#endregion
|
|
284
365
|
//#region src/converters/xlsx.ts
|
|
285
|
-
const { Workbook } = ExcelJS;
|
|
286
366
|
var XlsxConverter = class extends HtmlConverter {
|
|
287
367
|
async convert(source, options) {
|
|
288
368
|
if (options.file_extension?.toLowerCase() !== ".xlsx") return null;
|
|
289
|
-
const
|
|
290
|
-
await workbook.xlsx.load(toArrayBuffer(source));
|
|
369
|
+
const sheets = await readExcelFile(toArrayBuffer(source));
|
|
291
370
|
const sections = [];
|
|
292
|
-
for (const
|
|
293
|
-
const html =
|
|
371
|
+
for (const { sheet, data } of sheets) {
|
|
372
|
+
const html = sheetToHtml(data);
|
|
294
373
|
if (!html) continue;
|
|
295
374
|
const result = await this.convertHtml(html);
|
|
296
|
-
sections.push(`## ${
|
|
375
|
+
sections.push(`## ${sheet}\n${result?.markdown.trim() ?? ""}`);
|
|
297
376
|
}
|
|
298
377
|
const markdown = sections.join("\n\n");
|
|
299
378
|
return {
|
|
300
|
-
title:
|
|
379
|
+
title: null,
|
|
301
380
|
markdown,
|
|
302
381
|
text_content: markdown
|
|
303
382
|
};
|
|
304
383
|
}
|
|
305
384
|
};
|
|
306
|
-
function
|
|
307
|
-
const columnCount =
|
|
308
|
-
if (!columnCount ||
|
|
309
|
-
|
|
310
|
-
worksheet.eachRow({ includeEmpty: true }, (row) => {
|
|
385
|
+
function sheetToHtml(rows) {
|
|
386
|
+
const columnCount = rows.reduce((max, row) => Math.max(max, row.length), 0);
|
|
387
|
+
if (!columnCount || rows.length === 0) return "";
|
|
388
|
+
return `<html><body><table>${rows.map((row) => {
|
|
311
389
|
const cells = [];
|
|
312
|
-
for (let column =
|
|
313
|
-
|
|
314
|
-
})
|
|
315
|
-
return `<html><body><table>${rows.join("")}</table></body></html>`;
|
|
390
|
+
for (let column = 0; column < columnCount; column++) cells.push(`<td>${escapeHtml(cellText(row[column]))}</td>`);
|
|
391
|
+
return `<tr>${cells.join("")}</tr>`;
|
|
392
|
+
}).join("")}</table></body></html>`;
|
|
316
393
|
}
|
|
317
|
-
function cellText(
|
|
318
|
-
if (
|
|
319
|
-
return
|
|
394
|
+
function cellText(value) {
|
|
395
|
+
if (value == null) return "";
|
|
396
|
+
if (value instanceof Date) return value.toISOString();
|
|
397
|
+
return String(value);
|
|
320
398
|
}
|
|
321
399
|
function escapeHtml(value) {
|
|
322
400
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -515,6 +593,7 @@ var MarkItDown = class {
|
|
|
515
593
|
this.registerConverter(new BingSerpConverter());
|
|
516
594
|
this.registerConverter(new DocxConverter());
|
|
517
595
|
this.registerConverter(new XlsxConverter());
|
|
596
|
+
this.registerConverter(new PptxConverter());
|
|
518
597
|
this.registerConverter(new PdfConverter());
|
|
519
598
|
this.registerConverter(new IpynbConverter());
|
|
520
599
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/bytes.ts","../src/custom-turndown.ts","../src/html-document.ts","../src/converters/bingserp.ts","../src/converters/html.ts","../src/converters/docx.ts","../src/converters/ipynb.ts","../src/converters/pdf.ts","../src/mime.ts","../src/converters/plain-text.ts","../src/converters/wikipedia.ts","../src/converters/xlsx.ts","../src/converters/xml-rss-atom.ts","../src/converters/youtube.ts","../src/converters/zip.ts","../src/markitdown.ts"],"sourcesContent":["import type { ByteSource } from \"./types\";\n\nexport async function toUint8Array(source: ByteSource): Promise<Uint8Array> {\n if (source instanceof Uint8Array) {\n return source;\n }\n\n if (isBlob(source)) {\n return new Uint8Array(await source.arrayBuffer());\n }\n\n if (ArrayBuffer.isView(source)) {\n return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n\n return new Uint8Array(source);\n}\n\nexport function toArrayBuffer(source: Uint8Array): ArrayBuffer {\n return source.slice().buffer;\n}\n\nexport function decodeText(source: Uint8Array): string {\n return new TextDecoder().decode(source);\n}\n\nexport function isBlob(value: unknown): value is Blob {\n return typeof Blob !== \"undefined\" && value instanceof Blob;\n}\n\nexport function normalizeExtension(extension: string): string {\n if (!extension) {\n return \"\";\n }\n\n const normalized = extension.toLowerCase();\n return normalized.startsWith(\".\") ? normalized : `.${normalized}`;\n}\n","import turndownPluginGfm from \"@joplin/turndown-plugin-gfm\";\nimport TurndownService from \"turndown\";\n\nexport class CustomTurnDown {\n convertSoup(document: string | Node): string {\n const service = new TurndownService({ headingStyle: \"atx\" });\n service.use(turndownPluginGfm.gfm);\n\n service.addRule(\"anchor tags\", {\n filter: [\"a\"],\n replacement(content, node) {\n if (!content) return \"\";\n\n const prefix = content.startsWith(\" \") ? \" \" : \"\";\n const suffix = content.endsWith(\" \") ? \" \" : \"\";\n const text = content.trim().replace(/\\n\\n.*/g, \"\");\n if (!text) return \"\";\n\n const element = node as unknown as Element;\n const href = element.getAttribute(\"href\");\n let title = element.getAttribute(\"title\") ?? \"\";\n if (!href) return `${prefix}${text}${suffix}`;\n\n try {\n const url = new URL(href);\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n return `${prefix}${text}${suffix}`;\n }\n } catch {\n if (\n !href.startsWith(\"/\") &&\n !href.startsWith(\"#\") &&\n !href.startsWith(\"./\") &&\n !href.startsWith(\"../\")\n ) {\n return `${prefix}${text}${suffix}`;\n }\n }\n\n if (text.replace(/\\\\_/g, \"_\") === href && !title) {\n return `<${href}>`;\n }\n if (!title) title = href;\n return `${prefix}[${text}](${href}${title ? ` \"${title}\"` : \"\"})${suffix}`;\n }\n });\n\n service.addRule(\"img tags\", {\n filter: [\"img\"],\n replacement(_content, node) {\n const element = node as unknown as Element;\n const alt = element.getAttribute(\"alt\") ?? \"\";\n let source = element.getAttribute(\"src\") ?? \"\";\n const title = element.getAttribute(\"title\");\n if (source.startsWith(\"data:\")) {\n source = `${source.split(\",\", 1)[0]}...`;\n }\n return ``;\n }\n });\n\n return service.turndown(document as TurndownService.Node);\n }\n}\n","import { parseHTML } from \"linkedom\";\n\nexport function parseHtmlDocument(html: string): Document {\n return parseHTML(html).document as unknown as Document;\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nconst BING_SEARCH_URL = /^https:\\/\\/www\\.bing\\.com\\/search\\?q=/i;\nconst BASE64_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\nexport class BingSerpConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n const url = options.url ?? \"\";\n if ((extension !== \".html\" && extension !== \".htm\") || !BING_SEARCH_URL.test(url)) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n const query = new URL(url).searchParams.get(\"q\") ?? \"\";\n\n document.querySelectorAll(\".tptt\").forEach((element) => {\n if (element.textContent) {\n element.textContent += \" \";\n }\n });\n document.querySelectorAll(\".algoSlug_icon\").forEach((element) => {\n element.remove();\n });\n\n const turndown = new CustomTurnDown();\n const results = [...document.querySelectorAll(\".b_algo\")].map((result) => {\n result.querySelectorAll(\"a[href]\").forEach((anchor) => {\n const href = anchor.getAttribute(\"href\");\n if (!href) {\n return;\n }\n try {\n const encoded = new URL(href, url).searchParams.get(\"u\");\n if (encoded) {\n anchor.setAttribute(\"href\", decodeBingUrl(encoded));\n }\n } catch {\n // Preserve malformed links as they appeared in the source document.\n }\n });\n\n return turndown\n .convertSoup(result)\n .split(/\\n+/)\n .map((line) => line.trim())\n .filter(Boolean)\n .join(\"\\n\");\n });\n\n const markdown = `## A Bing search for '${query}' found the following results:\\n\\n${results.join(\"\\n\\n\")}`;\n return { title: document.title || null, markdown, text_content: markdown };\n }\n}\n\nfunction decodeBingUrl(encoded: string): string {\n const input = encoded.slice(2).replace(/-/g, \"+\").replace(/_/g, \"/\").replace(/=+$/, \"\");\n const bytes: number[] = [];\n let bits = 0;\n let bitCount = 0;\n\n for (const character of input) {\n const value = BASE64_ALPHABET.indexOf(character);\n if (value < 0) {\n return encoded;\n }\n bits = (bits << 6) | value;\n bitCount += 6;\n if (bitCount >= 8) {\n bitCount -= 8;\n bytes.push((bits >> bitCount) & 0xff);\n }\n }\n\n return new TextDecoder().decode(new Uint8Array(bytes));\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class HtmlConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (extension !== \".html\" && extension !== \".htm\") {\n return null;\n }\n\n return this.convertHtml(decodeText(source));\n }\n\n async convertHtml(html: string): Promise<ConverterResult> {\n const document = parseHtmlDocument(html);\n\n const title = document.title;\n document.querySelectorAll(\"script, style, title\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document);\n return {\n title: title || null,\n markdown,\n text_content: markdown\n };\n }\n}\n","import mammoth from \"mammoth\";\nimport { toArrayBuffer } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult } from \"../types\";\nimport { HtmlConverter } from \"./html\";\n\nexport class DocxConverter extends HtmlConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".docx\") {\n return null;\n }\n\n let mammothInput: Parameters<typeof mammoth.convertToHtml>[0] = {\n arrayBuffer: toArrayBuffer(source)\n };\n\n if (\n typeof process !== \"undefined\" &&\n process.versions !== null &&\n process.versions.node !== null\n ) {\n mammothInput = { buffer: Buffer.from(source) };\n }\n\n const mammothOptions: Parameters<typeof mammoth.convertToHtml>[1] = {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix\n };\n\n if (options.transformDocument) {\n mammothOptions.transformDocument = options.transformDocument;\n }\n\n const html = await mammoth.convertToHtml(mammothInput, mammothOptions);\n\n return this.convertHtml(html.value);\n }\n}\n","import { decodeText } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\ntype NotebookCell = {\n cell_type?: string;\n source?: string[];\n};\n\ntype Notebook = {\n cells?: NotebookCell[];\n metadata?: { title?: string };\n};\n\nexport class IpynbConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".ipynb\") {\n return null;\n }\n\n const notebook = JSON.parse(decodeText(source)) as Notebook;\n const output: string[] = [];\n let title: string | null = notebook.metadata?.title ?? null;\n\n for (const cell of notebook.cells ?? []) {\n const lines = cell.source ?? [];\n if (cell.cell_type === \"markdown\") {\n output.push(lines.join(\"\"));\n title ??=\n lines\n .find((line) => line.startsWith(\"# \"))\n ?.slice(2)\n .trim() ?? null;\n } else if (cell.cell_type === \"code\") {\n output.push(`\\`\\`\\`python\\n${lines.join(\"\")}\\n\\`\\`\\``);\n } else if (cell.cell_type === \"raw\") {\n output.push(`\\`\\`\\`\\n${lines.join(\"\")}\\n\\`\\`\\``);\n }\n }\n\n const markdown = output.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n","import { extractText, getDocumentProxy, getMeta } from \"unpdf\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class PdfConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".pdf\") {\n return null;\n }\n\n const pdf = await getDocumentProxy(source.slice());\n try {\n const [{ text }, { info }] = await Promise.all([\n extractText(pdf, { mergePages: true }),\n getMeta(pdf)\n ]);\n const title = typeof info.Title === \"string\" && info.Title.trim() ? info.Title : null;\n\n return { title, markdown: text, text_content: text };\n } finally {\n await pdf.loadingTask.destroy();\n }\n }\n}\n","const MIME_EXTENSIONS: Record<string, string> = {\n \"application/atom+xml\": \".atom\",\n \"application/json\": \".json\",\n \"application/pdf\": \".pdf\",\n \"application/zip\": \".zip\",\n \"application/rss+xml\": \".rss\",\n \"application/x-pdf\": \".pdf\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \".xlsx\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \".docx\",\n \"application/xml\": \".xml\",\n \"text/csv\": \".csv\",\n \"text/html\": \".html\",\n \"text/markdown\": \".md\",\n \"text/plain\": \".txt\",\n \"text/xml\": \".xml\"\n};\n\nconst TEXT_EXTENSIONS = new Set([\".csv\", \".json\", \".log\", \".markdown\", \".md\", \".text\", \".txt\"]);\n\nexport function extensionFromMime(contentType: string | null | undefined): string | null {\n if (!contentType) {\n return null;\n }\n\n const mime = contentType.split(\";\", 1)[0]?.trim().toLowerCase() ?? \"\";\n return MIME_EXTENSIONS[mime] ?? (mime.startsWith(\"text/\") ? \".txt\" : null);\n}\n\nexport function isTextExtension(extension: string): boolean {\n return TEXT_EXTENSIONS.has(extension.toLowerCase());\n}\n\nexport function extensionFromPathname(pathname: string): string | null {\n const filename = pathname.split(\"/\").pop() ?? \"\";\n const dot = filename.lastIndexOf(\".\");\n return dot > 0 ? filename.slice(dot).toLowerCase() : null;\n}\n","import { decodeText } from \"../bytes\";\nimport { isTextExtension } from \"../mime\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class PlainTextConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (!isTextExtension(options.file_extension ?? \"\")) {\n return null;\n }\n\n const content = decodeText(source);\n return { title: null, markdown: content, text_content: content };\n }\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nconst WIKIPEDIA_URL = /^https?:\\/\\/[a-z]{2,3}\\.wikipedia\\.org\\//i;\n\nexport class WikipediaConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if ((extension !== \".html\" && extension !== \".htm\") || !WIKIPEDIA_URL.test(options.url ?? \"\")) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const body = document.querySelector(\"div#mw-content-text\");\n const pageTitle = document.querySelector(\"span.mw-page-title-main\")?.textContent?.trim();\n const title = pageTitle || document.title || null;\n const markdown = body\n ? `# ${title ?? \"Wikipedia\"}\\n\\n${new CustomTurnDown().convertSoup(body)}`\n : new CustomTurnDown().convertSoup(document);\n\n return { title, markdown, text_content: markdown };\n }\n}\n","import ExcelJS, { type Cell, type Worksheet } from \"exceljs\";\nimport { toArrayBuffer } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult } from \"../types\";\nimport { HtmlConverter } from \"./html\";\n\nconst { Workbook } = ExcelJS;\n\nexport class XlsxConverter extends HtmlConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".xlsx\") {\n return null;\n }\n\n const workbook = new Workbook();\n await workbook.xlsx.load(toArrayBuffer(source));\n const sections: string[] = [];\n\n for (const worksheet of workbook.worksheets) {\n const html = worksheetToHtml(worksheet);\n if (!html) {\n continue;\n }\n const result = await this.convertHtml(html);\n sections.push(`## ${worksheet.name}\\n${result?.markdown.trim() ?? \"\"}`);\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return {\n title: workbook.title || \"Untitled\",\n markdown,\n text_content: markdown\n };\n }\n}\n\nfunction worksheetToHtml(worksheet: Worksheet): string {\n const columnCount = worksheet.columnCount;\n if (!columnCount || !worksheet.actualRowCount) {\n return \"\";\n }\n\n const rows: string[] = [];\n worksheet.eachRow({ includeEmpty: true }, (row) => {\n const cells: string[] = [];\n for (let column = 1; column <= columnCount; column++) {\n cells.push(`<td>${escapeHtml(cellText(row.getCell(column)))}</td>`);\n }\n rows.push(`<tr>${cells.join(\"\")}</tr>`);\n });\n\n return `<html><body><table>${rows.join(\"\")}</table></body></html>`;\n}\n\nfunction cellText(cell: Cell): string {\n if (cell.isMerged && cell.master !== cell) {\n return \"\";\n }\n return cell.text;\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n","import type { Document, Element } from \"@xmldom/xmldom\";\nimport { DOMParser } from \"@xmldom/xmldom\";\nimport { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class RSSConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (![\".xml\", \".rss\", \".atom\"].includes(extension)) {\n return null;\n }\n\n const document = new DOMParser().parseFromString(decodeText(source), \"text/xml\");\n if (document.getElementsByTagName(\"rss\").length > 0) {\n return this.parseRss(document);\n }\n if (document.getElementsByTagName(\"feed\")[0]?.getElementsByTagName(\"entry\").length) {\n return this.parseAtom(document);\n }\n return null;\n }\n\n private parseAtom(document: Document): ConverterResult {\n const root = document.getElementsByTagName(\"feed\")[0];\n if (!root) return null;\n\n const title = getText(root, \"title\");\n const subtitle = getText(root, \"subtitle\");\n const sections = [`# ${title ?? \"Feed\"}`];\n if (subtitle) sections.push(subtitle);\n\n for (const entry of [...root.getElementsByTagName(\"entry\")]) {\n const entryTitle = getText(entry, \"title\");\n const updated = getText(entry, \"updated\");\n const summary = getText(entry, \"summary\");\n const content = getText(entry, \"content\");\n const lines: string[] = [];\n if (entryTitle) lines.push(`## ${entryTitle}`);\n if (updated) lines.push(`Updated on: ${updated}`);\n if (summary) lines.push(parseContent(summary));\n if (content) lines.push(parseContent(content));\n sections.push(lines.join(\"\\n\"));\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n\n private parseRss(document: Document): ConverterResult {\n const channel = document.getElementsByTagName(\"rss\")[0]?.getElementsByTagName(\"channel\")[0];\n if (!channel) return null;\n\n const title = getText(channel, \"title\");\n const description = getText(channel, \"description\");\n const sections: string[] = title ? [`# ${title}`] : [];\n if (description) sections.push(description);\n\n for (const item of [...channel.getElementsByTagName(\"item\")]) {\n const itemTitle = getText(item, \"title\");\n const published = getText(item, \"pubDate\");\n const itemDescription = getText(item, \"description\");\n const content = getText(item, \"content:encoded\");\n const lines: string[] = [];\n if (itemTitle) lines.push(`## ${itemTitle}`);\n if (published) lines.push(`Published on: ${published}`);\n if (itemDescription) lines.push(parseContent(itemDescription));\n if (content) lines.push(parseContent(content));\n sections.push(lines.join(\"\\n\"));\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n\nfunction parseContent(content: string): string {\n return new CustomTurnDown().convertSoup(parseHtmlDocument(content).documentElement);\n}\n\nfunction getText(element: Element, tagName: string): string | null {\n const node = element.getElementsByTagName(tagName)[0];\n return node?.textContent?.trim() || null;\n}\n","import { decodeText } from \"../bytes\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class YouTubeConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (\n (extension !== \".html\" && extension !== \".htm\") ||\n !options.url?.startsWith(\"https://www.youtube.com/watch?\")\n ) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n const metadata: Record<string, string> = { title: document.title };\n\n document.querySelectorAll(\"meta\").forEach((meta) => {\n const content = meta.getAttribute(\"content\");\n const key =\n meta.getAttribute(\"itemprop\") ?? meta.getAttribute(\"property\") ?? meta.getAttribute(\"name\");\n if (key && content) {\n metadata[key] = content;\n }\n });\n\n try {\n for (const script of document.querySelectorAll(\"script\")) {\n const content = script.textContent ?? \"\";\n if (!content.includes(\"ytInitialData\")) {\n continue;\n }\n const start = content.indexOf(\"{\");\n const end = content.lastIndexOf(\"}\");\n if (start >= 0 && end > start) {\n const description = findKey(\n JSON.parse(content.slice(start, end + 1)),\n \"attributedDescriptionBodyText\"\n );\n if (isRecord(description) && typeof description.content === \"string\") {\n metadata.description = description.content;\n }\n }\n break;\n }\n } catch {\n // Meta description remains available when the page implementation changes.\n }\n\n const title = first(metadata, [\"title\", \"og:title\", \"name\"]) || document.title || null;\n const lines = [\"# YouTube\"];\n if (title) {\n lines.push(`## ${title}`);\n }\n\n const stats: string[] = [];\n const views = first(metadata, [\"interactionCount\"]);\n const keywords = first(metadata, [\"keywords\"]);\n const runtime = first(metadata, [\"duration\"]);\n if (views) stats.push(`- **Views:** ${views}`);\n if (keywords) stats.push(`- **Keywords:** ${keywords}`);\n if (runtime) stats.push(`- **Runtime:** ${runtime}`);\n if (stats.length > 0) {\n lines.push(`### Video Metadata\\n${stats.join(\"\\n\")}`);\n }\n\n const description = first(metadata, [\"description\", \"og:description\"]);\n if (description) {\n lines.push(`### Description\\n${description}`);\n }\n\n const markdown = lines.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n\nfunction first(metadata: Record<string, string>, keys: string[]): string | null {\n for (const key of keys) {\n if (metadata[key]) return metadata[key];\n }\n return null;\n}\n\nfunction findKey(value: unknown, key: string): unknown {\n if (Array.isArray(value)) {\n for (const item of value) {\n const match = findKey(item, key);\n if (match !== undefined) return match;\n }\n } else if (isRecord(value)) {\n if (key in value) return value[key];\n for (const item of Object.values(value)) {\n const match = findKey(item, key);\n if (match !== undefined) return match;\n }\n }\n return undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n","import { unzipSync } from \"fflate\";\nimport { extensionFromPathname } from \"../mime\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class ZipConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".zip\") {\n return null;\n }\n\n const files = unzipSync(source, {\n filter: (file) => !file.name.endsWith(\"/\")\n });\n const converters = options._parent_converters ?? [];\n const zipName = options.url ?? \"archive.zip\";\n const sections = [`Content from the zip file \\`${zipName}\\`:`];\n\n for (const [name, bytes] of Object.entries(files)) {\n const result = await convertEntry(bytes, name, converters, options);\n if (result) {\n sections.push(`## File: ${name}\\n\\n${result.markdown}`);\n }\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title: null, markdown, text_content: markdown };\n }\n}\n\nasync function convertEntry(\n source: Uint8Array,\n name: string,\n converters: DocumentConverter[],\n options: ConverterOptions\n): Promise<ConverterResult> {\n const extension = extensionFromPathname(name);\n if (!extension) {\n return null;\n }\n\n const entryOptions: ConverterOptions = {\n ...options,\n file_extension: extension,\n url: undefined,\n _parent_converters: converters\n };\n\n for (const converter of converters) {\n try {\n const result = await converter.convert(source, entryOptions);\n if (result) {\n return result;\n }\n } catch {\n // Match the original ZipConverter: skip entries that fail conversion.\n }\n }\n\n return null;\n}\n","import { isBlob, toUint8Array } from \"./bytes\";\nimport { BingSerpConverter } from \"./converters/bingserp\";\nimport { DocxConverter } from \"./converters/docx\";\nimport { HtmlConverter } from \"./converters/html\";\nimport { IpynbConverter } from \"./converters/ipynb\";\nimport { PdfConverter } from \"./converters/pdf\";\nimport { PlainTextConverter } from \"./converters/plain-text\";\nimport { WikipediaConverter } from \"./converters/wikipedia\";\nimport { XlsxConverter } from \"./converters/xlsx\";\nimport { RSSConverter } from \"./converters/xml-rss-atom\";\nimport { YouTubeConverter } from \"./converters/youtube\";\nimport { ZipConverter } from \"./converters/zip\";\nimport { extensionFromMime, extensionFromPathname } from \"./mime\";\nimport type { ByteSource, ConverterOptions, ConverterResult, DocumentConverter } from \"./types\";\n\nexport type ConversionSource = ByteSource | Response | URL | string;\n\nexport class MarkItDown {\n private readonly converters: DocumentConverter[] = [];\n\n constructor() {\n this.registerConverter(new PlainTextConverter());\n this.registerConverter(new HtmlConverter());\n this.registerConverter(new ZipConverter());\n this.registerConverter(new RSSConverter());\n this.registerConverter(new WikipediaConverter());\n this.registerConverter(new YouTubeConverter());\n this.registerConverter(new BingSerpConverter());\n this.registerConverter(new DocxConverter());\n this.registerConverter(new XlsxConverter());\n this.registerConverter(new PdfConverter());\n this.registerConverter(new IpynbConverter());\n }\n\n /** Convert a URL, response, blob, array buffer, data view, or typed array. */\n async convert(\n source: ConversionSource,\n options: ConverterOptions = {}\n ): Promise<ConverterResult> {\n if (typeof source === \"string\" || source instanceof URL) {\n return this.convertUrl(source.toString(), options);\n }\n\n if (isResponse(source)) {\n return this.convertResponse(source, options);\n }\n\n const extensions = new Set<string>();\n this.addExtension(extensions, options.file_extension?.replace(/^\\./, \"\"));\n\n if (isBlob(source)) {\n this.addExtension(extensions, extensionFromMime(source.type));\n if (\"name\" in source && typeof source.name === \"string\") {\n this.addExtension(extensions, extensionFromPathname(source.name));\n }\n }\n\n if (extensions.size === 0) {\n throw new Error(\n \"Could not determine the file type. Provide `file_extension` when converting bytes.\"\n );\n }\n\n return this.convertBytes(await toUint8Array(source), extensions, options);\n }\n\n /**\n * @deprecated Pass the byte source directly to `convert`.\n */\n async convertBuffer(\n source: ByteSource,\n options: ConverterOptions & { file_extension: string }\n ): Promise<ConverterResult> {\n return this.convert(source, options);\n }\n\n private async convertUrl(\n source: string,\n { fetch: fetchImplementation = globalThis.fetch, ...options }: ConverterOptions\n ): Promise<ConverterResult> {\n const url = new URL(source);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new Error(`Unsupported URL protocol: ${url.protocol}`);\n }\n if (!fetchImplementation) {\n throw new Error(\"No fetch implementation is available.\");\n }\n\n const response = await fetchImplementation(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch URL: ${url}, status: ${response.status}`);\n }\n\n return this.convertResponse(response, { ...options, url: url.toString() });\n }\n\n private async convertResponse(\n response: Response,\n options: ConverterOptions\n ): Promise<ConverterResult> {\n const extensions = new Set<string>();\n this.addExtension(extensions, options.file_extension);\n this.addExtension(extensions, extensionFromMime(response.headers.get(\"content-type\")));\n\n const disposition = response.headers.get(\"content-disposition\") ?? \"\";\n const filename = disposition.match(/filename\\*?=(?:UTF-8''|[\"']?)([^;\"']+)/i)?.[1];\n if (filename) {\n this.addExtension(extensions, extensionFromPathname(decodeURIComponent(filename.trim())));\n }\n\n const responseUrl = options.url || response.url;\n if (responseUrl) {\n this.addExtension(extensions, extensionFromPathname(new URL(responseUrl).pathname));\n }\n\n if (extensions.size === 0) {\n throw new Error(\n \"Could not determine the file type. Provide `file_extension` or a Content-Type header.\"\n );\n }\n\n return this.convertBytes(new Uint8Array(await response.arrayBuffer()), extensions, {\n ...options,\n url: responseUrl\n });\n }\n\n private async convertBytes(\n source: Uint8Array,\n extensions: Set<string>,\n options: ConverterOptions\n ): Promise<ConverterResult> {\n let lastError: unknown;\n\n for (const extension of extensions) {\n for (const converter of this.converters) {\n try {\n const result = await converter.convert(source, {\n ...options,\n file_extension: extension,\n _parent_converters: this.converters\n });\n if (result) {\n result.markdown = result.markdown\n .replace(/\\r\\n|\\r|\\n/g, \"\\n\")\n .trim()\n .replace(/\\n{3,}/g, \"\\n\\n\");\n result.text_content = result.markdown;\n return result;\n }\n } catch (error) {\n if (options.debug) {\n console.error(\"Converter threw error:\", error);\n }\n lastError = error;\n }\n }\n }\n\n const formats = [...extensions].join(\", \");\n if (lastError) {\n throw new Error(`Could not convert ${formats} to Markdown: ${String(lastError)}`);\n }\n throw new Error(`Unsupported file type: ${formats}.`);\n }\n\n private addExtension(extensions: Set<string>, extension: string | null | undefined): void {\n if (!extension) {\n return;\n }\n extensions.add(\n extension.startsWith(\".\") ? extension.toLowerCase() : `.${extension.toLowerCase()}`\n );\n }\n\n private registerConverter(converter: DocumentConverter): void {\n this.converters.unshift(converter);\n }\n}\n\nfunction isResponse(value: unknown): value is Response {\n return typeof Response !== \"undefined\" && value instanceof Response;\n}\n"],"mappings":";;;;;;;;;AAEA,eAAsB,aAAa,QAAyC;CAC1E,IAAI,kBAAkB,YACpB,OAAO;CAGT,IAAI,OAAO,MAAM,GACf,OAAO,IAAI,WAAW,MAAM,OAAO,YAAY,CAAC;CAGlD,IAAI,YAAY,OAAO,MAAM,GAC3B,OAAO,IAAI,WAAW,OAAO,QAAQ,OAAO,YAAY,OAAO,UAAU;CAG3E,OAAO,IAAI,WAAW,MAAM;AAC9B;AAEA,SAAgB,cAAc,QAAiC;CAC7D,OAAO,OAAO,MAAM,CAAC,CAAC;AACxB;AAEA,SAAgB,WAAW,QAA4B;CACrD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM;AACxC;AAEA,SAAgB,OAAO,OAA+B;CACpD,OAAO,OAAO,SAAS,eAAe,iBAAiB;AACzD;;;ACzBA,IAAa,iBAAb,MAA4B;CAC1B,YAAY,UAAiC;EAC3C,MAAM,UAAU,IAAI,gBAAgB,EAAE,cAAc,MAAM,CAAC;EAC3D,QAAQ,IAAI,kBAAkB,GAAG;EAEjC,QAAQ,QAAQ,eAAe;GAC7B,QAAQ,CAAC,GAAG;GACZ,YAAY,SAAS,MAAM;IACzB,IAAI,CAAC,SAAS,OAAO;IAErB,MAAM,SAAS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|
+
{"version":3,"file":"index.js","names":["XmlElement","XmlDocument","XmlNode"],"sources":["../src/bytes.ts","../src/custom-turndown.ts","../src/html-document.ts","../src/converters/bingserp.ts","../src/converters/html.ts","../src/converters/docx.ts","../src/converters/ipynb.ts","../src/converters/pdf.ts","../src/mime.ts","../src/converters/plain-text.ts","../src/converters/pptx.ts","../src/converters/wikipedia.ts","../src/converters/xlsx.ts","../src/converters/xml-rss-atom.ts","../src/converters/youtube.ts","../src/converters/zip.ts","../src/markitdown.ts"],"sourcesContent":["import type { ByteSource } from \"./types\";\n\nexport async function toUint8Array(source: ByteSource): Promise<Uint8Array> {\n if (source instanceof Uint8Array) {\n return source;\n }\n\n if (isBlob(source)) {\n return new Uint8Array(await source.arrayBuffer());\n }\n\n if (ArrayBuffer.isView(source)) {\n return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n\n return new Uint8Array(source);\n}\n\nexport function toArrayBuffer(source: Uint8Array): ArrayBuffer {\n return source.slice().buffer;\n}\n\nexport function decodeText(source: Uint8Array): string {\n return new TextDecoder().decode(source);\n}\n\nexport function isBlob(value: unknown): value is Blob {\n return typeof Blob !== \"undefined\" && value instanceof Blob;\n}\n\nexport function normalizeExtension(extension: string): string {\n if (!extension) {\n return \"\";\n }\n\n const normalized = extension.toLowerCase();\n return normalized.startsWith(\".\") ? normalized : `.${normalized}`;\n}\n","import turndownPluginGfm from \"@joplin/turndown-plugin-gfm\";\nimport TurndownService from \"turndown\";\n\nexport class CustomTurnDown {\n convertSoup(document: string | Node): string {\n const service = new TurndownService({ headingStyle: \"atx\" });\n service.use(turndownPluginGfm.gfm);\n\n service.addRule(\"anchor tags\", {\n filter: [\"a\"],\n replacement(content, node) {\n if (!content) return \"\";\n\n const prefix = content.startsWith(\" \") ? \" \" : \"\";\n const suffix = content.endsWith(\" \") ? \" \" : \"\";\n const text = content.trim().replace(/\\n\\n.*/g, \"\");\n if (!text) return \"\";\n\n const element = node as unknown as Element;\n const href = element.getAttribute(\"href\");\n let title = element.getAttribute(\"title\") ?? \"\";\n if (!href) return `${prefix}${text}${suffix}`;\n\n try {\n const url = new URL(href);\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n return `${prefix}${text}${suffix}`;\n }\n } catch {\n if (\n !href.startsWith(\"/\") &&\n !href.startsWith(\"#\") &&\n !href.startsWith(\"./\") &&\n !href.startsWith(\"../\")\n ) {\n return `${prefix}${text}${suffix}`;\n }\n }\n\n if (text.replace(/\\\\_/g, \"_\") === href && !title) {\n return `<${href}>`;\n }\n if (!title) title = href;\n return `${prefix}[${text}](${href}${title ? ` \"${title}\"` : \"\"})${suffix}`;\n }\n });\n\n service.addRule(\"img tags\", {\n filter: [\"img\"],\n replacement(_content, node) {\n const element = node as unknown as Element;\n const alt = element.getAttribute(\"alt\") ?? \"\";\n let source = element.getAttribute(\"src\") ?? \"\";\n const title = element.getAttribute(\"title\");\n if (source.startsWith(\"data:\")) {\n source = `${source.split(\",\", 1)[0]}...`;\n }\n return ``;\n }\n });\n\n return service.turndown(document as TurndownService.Node);\n }\n}\n","import { parseHTML } from \"linkedom\";\n\nexport function parseHtmlDocument(html: string): Document {\n return parseHTML(html).document as unknown as Document;\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nconst BING_SEARCH_URL = /^https:\\/\\/www\\.bing\\.com\\/search\\?q=/i;\nconst BASE64_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\nexport class BingSerpConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n const url = options.url ?? \"\";\n if ((extension !== \".html\" && extension !== \".htm\") || !BING_SEARCH_URL.test(url)) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n const query = new URL(url).searchParams.get(\"q\") ?? \"\";\n\n document.querySelectorAll(\".tptt\").forEach((element) => {\n if (element.textContent) {\n element.textContent += \" \";\n }\n });\n document.querySelectorAll(\".algoSlug_icon\").forEach((element) => {\n element.remove();\n });\n\n const turndown = new CustomTurnDown();\n const results = [...document.querySelectorAll(\".b_algo\")].map((result) => {\n result.querySelectorAll(\"a[href]\").forEach((anchor) => {\n const href = anchor.getAttribute(\"href\");\n if (!href) {\n return;\n }\n try {\n const encoded = new URL(href, url).searchParams.get(\"u\");\n if (encoded) {\n anchor.setAttribute(\"href\", decodeBingUrl(encoded));\n }\n } catch {\n // Preserve malformed links as they appeared in the source document.\n }\n });\n\n return turndown\n .convertSoup(result)\n .split(/\\n+/)\n .map((line) => line.trim())\n .filter(Boolean)\n .join(\"\\n\");\n });\n\n const markdown = `## A Bing search for '${query}' found the following results:\\n\\n${results.join(\"\\n\\n\")}`;\n return { title: document.title || null, markdown, text_content: markdown };\n }\n}\n\nfunction decodeBingUrl(encoded: string): string {\n const input = encoded.slice(2).replace(/-/g, \"+\").replace(/_/g, \"/\").replace(/=+$/, \"\");\n const bytes: number[] = [];\n let bits = 0;\n let bitCount = 0;\n\n for (const character of input) {\n const value = BASE64_ALPHABET.indexOf(character);\n if (value < 0) {\n return encoded;\n }\n bits = (bits << 6) | value;\n bitCount += 6;\n if (bitCount >= 8) {\n bitCount -= 8;\n bytes.push((bits >> bitCount) & 0xff);\n }\n }\n\n return new TextDecoder().decode(new Uint8Array(bytes));\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class HtmlConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (extension !== \".html\" && extension !== \".htm\") {\n return null;\n }\n\n return this.convertHtml(decodeText(source));\n }\n\n async convertHtml(html: string): Promise<ConverterResult> {\n const document = parseHtmlDocument(html);\n\n const title = document.title;\n document.querySelectorAll(\"script, style, title\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document);\n return {\n title: title || null,\n markdown,\n text_content: markdown\n };\n }\n}\n","import mammoth from \"mammoth\";\nimport { toArrayBuffer } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult } from \"../types\";\nimport { HtmlConverter } from \"./html\";\n\nexport class DocxConverter extends HtmlConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".docx\") {\n return null;\n }\n\n let mammothInput: Parameters<typeof mammoth.convertToHtml>[0] = {\n arrayBuffer: toArrayBuffer(source)\n };\n\n if (\n typeof process !== \"undefined\" &&\n process.versions !== null &&\n process.versions.node !== null\n ) {\n mammothInput = { buffer: Buffer.from(source) };\n }\n\n const mammothOptions: Parameters<typeof mammoth.convertToHtml>[1] = {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix\n };\n\n if (options.transformDocument) {\n mammothOptions.transformDocument = options.transformDocument;\n }\n\n const html = await mammoth.convertToHtml(mammothInput, mammothOptions);\n\n return this.convertHtml(html.value);\n }\n}\n","import { decodeText } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\ntype NotebookCell = {\n cell_type?: string;\n source?: string[];\n};\n\ntype Notebook = {\n cells?: NotebookCell[];\n metadata?: { title?: string };\n};\n\nexport class IpynbConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".ipynb\") {\n return null;\n }\n\n const notebook = JSON.parse(decodeText(source)) as Notebook;\n const output: string[] = [];\n let title: string | null = notebook.metadata?.title ?? null;\n\n for (const cell of notebook.cells ?? []) {\n const lines = cell.source ?? [];\n if (cell.cell_type === \"markdown\") {\n output.push(lines.join(\"\"));\n title ??=\n lines\n .find((line) => line.startsWith(\"# \"))\n ?.slice(2)\n .trim() ?? null;\n } else if (cell.cell_type === \"code\") {\n output.push(`\\`\\`\\`python\\n${lines.join(\"\")}\\n\\`\\`\\``);\n } else if (cell.cell_type === \"raw\") {\n output.push(`\\`\\`\\`\\n${lines.join(\"\")}\\n\\`\\`\\``);\n }\n }\n\n const markdown = output.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n","import { extractText, getDocumentProxy, getMeta } from \"unpdf\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class PdfConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".pdf\") {\n return null;\n }\n\n const pdf = await getDocumentProxy(source.slice());\n try {\n const [{ text }, { info }] = await Promise.all([\n extractText(pdf, { mergePages: true }),\n getMeta(pdf)\n ]);\n const title = typeof info.Title === \"string\" && info.Title.trim() ? info.Title : null;\n\n return { title, markdown: text, text_content: text };\n } finally {\n await pdf.loadingTask.destroy();\n }\n }\n}\n","const MIME_EXTENSIONS: Record<string, string> = {\n \"application/atom+xml\": \".atom\",\n \"application/json\": \".json\",\n \"application/pdf\": \".pdf\",\n \"application/zip\": \".zip\",\n \"application/rss+xml\": \".rss\",\n \"application/x-pdf\": \".pdf\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": \".pptx\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \".xlsx\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \".docx\",\n \"application/xml\": \".xml\",\n \"text/csv\": \".csv\",\n \"text/html\": \".html\",\n \"text/markdown\": \".md\",\n \"text/plain\": \".txt\",\n \"text/xml\": \".xml\"\n};\n\nconst TEXT_EXTENSIONS = new Set([\".csv\", \".json\", \".log\", \".markdown\", \".md\", \".text\", \".txt\"]);\n\nexport function extensionFromMime(contentType: string | null | undefined): string | null {\n if (!contentType) {\n return null;\n }\n\n const mime = contentType.split(\";\", 1)[0]?.trim().toLowerCase() ?? \"\";\n return MIME_EXTENSIONS[mime] ?? (mime.startsWith(\"text/\") ? \".txt\" : null);\n}\n\nexport function isTextExtension(extension: string): boolean {\n return TEXT_EXTENSIONS.has(extension.toLowerCase());\n}\n\nexport function extensionFromPathname(pathname: string): string | null {\n const filename = pathname.split(\"/\").pop() ?? \"\";\n const dot = filename.lastIndexOf(\".\");\n return dot > 0 ? filename.slice(dot).toLowerCase() : null;\n}\n","import { decodeText } from \"../bytes\";\nimport { isTextExtension } from \"../mime\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class PlainTextConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (!isTextExtension(options.file_extension ?? \"\")) {\n return null;\n }\n\n const content = decodeText(source);\n return { title: null, markdown: content, text_content: content };\n }\n}\n","import { pptxToHtml } from \"@jvmr/pptx-to-html\";\nimport {\n DOMParser,\n Document as XmlDocument,\n Element as XmlElement,\n Node as XmlNode\n} from \"@xmldom/xmldom\";\nimport { toArrayBuffer } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult } from \"../types\";\nimport { HtmlConverter } from \"./html\";\n\nexport class PptxConverter extends HtmlConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".pptx\") {\n return null;\n }\n\n const slides = await pptxToHtml(toArrayBuffer(source), {\n domParserFactory: createPptxDomParser\n });\n const sections: string[] = [];\n\n for (const [index, html] of slides.entries()) {\n const result = await this.convertHtml(`<html><body>${html}</body></html>`);\n sections.push(`<!-- Slide number: ${index + 1} -->\\n${result?.markdown.trim() ?? \"\"}`);\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return {\n title: null,\n markdown,\n text_content: markdown\n };\n }\n}\n\nfunction createPptxDomParser(): { parseFromString(xml: string, mime: string): Document } {\n if (typeof globalThis.DOMParser === \"function\") {\n return new globalThis.DOMParser();\n }\n\n patchXmlDom();\n return new DOMParser() as unknown as {\n parseFromString(xml: string, mime: string): Document;\n };\n}\n\nlet xmlDomPatched = false;\n\nfunction patchXmlDom(): void {\n if (xmlDomPatched) {\n return;\n }\n xmlDomPatched = true;\n\n defineMethod(XmlElement.prototype, \"querySelector\", querySelector);\n defineMethod(XmlElement.prototype, \"querySelectorAll\", querySelectorAll);\n defineMethod(XmlDocument.prototype, \"querySelector\", querySelector);\n defineMethod(XmlDocument.prototype, \"querySelectorAll\", querySelectorAll);\n\n defineGetter(XmlElement.prototype, \"children\", function (this: XmlElement) {\n return [...this.childNodes].filter((node) => node.nodeType === 1);\n });\n defineGetter(XmlNode.prototype, \"parentElement\", function (this: XmlNode) {\n const parent = this.parentNode;\n return parent?.nodeType === 1 ? parent : null;\n });\n}\n\nfunction querySelector(this: XmlElement | XmlDocument, selector: string): XmlElement | null {\n for (const group of selector.split(\",\")) {\n const match = queryByPath(this, group.trim());\n if (match) {\n return match;\n }\n }\n return null;\n}\n\nfunction querySelectorAll(): XmlElement[] {\n return [];\n}\n\nfunction queryByPath(root: XmlElement | XmlDocument, selector: string): XmlElement | null {\n const tokens = selector.split(/\\s+/).filter(Boolean);\n let current: Array<XmlElement | XmlDocument> = [root];\n\n for (const token of tokens) {\n const localName = selectorLocalName(token);\n const next: XmlElement[] = [];\n for (const node of current) {\n next.push(...Array.from(node.getElementsByTagNameNS(\"*\", localName)));\n }\n current = next;\n }\n\n return (current[0] as XmlElement | undefined) ?? null;\n}\n\nfunction selectorLocalName(token: string): string {\n if (token.includes(\"|\")) {\n return token.slice(token.lastIndexOf(\"|\") + 1);\n }\n return token.replace(/\\\\:/g, \":\").split(\":\").pop() ?? token;\n}\n\nfunction defineMethod(target: object, name: string, value: (...args: never[]) => unknown): void {\n Object.defineProperty(target, name, { configurable: true, writable: true, value });\n}\n\nfunction defineGetter(target: object, name: string, get: () => unknown): void {\n if (Object.getOwnPropertyDescriptor(target, name)) {\n return;\n }\n Object.defineProperty(target, name, { configurable: true, get });\n}\n","import { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nconst WIKIPEDIA_URL = /^https?:\\/\\/[a-z]{2,3}\\.wikipedia\\.org\\//i;\n\nexport class WikipediaConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if ((extension !== \".html\" && extension !== \".htm\") || !WIKIPEDIA_URL.test(options.url ?? \"\")) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const body = document.querySelector(\"div#mw-content-text\");\n const pageTitle = document.querySelector(\"span.mw-page-title-main\")?.textContent?.trim();\n const title = pageTitle || document.title || null;\n const markdown = body\n ? `# ${title ?? \"Wikipedia\"}\\n\\n${new CustomTurnDown().convertSoup(body)}`\n : new CustomTurnDown().convertSoup(document);\n\n return { title, markdown, text_content: markdown };\n }\n}\n","import readExcelFile, { type SheetData } from \"read-excel-file/universal\";\nimport { toArrayBuffer } from \"../bytes\";\nimport type { ConverterOptions, ConverterResult } from \"../types\";\nimport { HtmlConverter } from \"./html\";\n\nexport class XlsxConverter extends HtmlConverter {\n async convert(source: Uint8Array, options: ConverterOptions): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".xlsx\") {\n return null;\n }\n\n const sheets = await readExcelFile(toArrayBuffer(source));\n const sections: string[] = [];\n\n for (const { sheet, data } of sheets) {\n const html = sheetToHtml(data);\n if (!html) {\n continue;\n }\n const result = await this.convertHtml(html);\n sections.push(`## ${sheet}\\n${result?.markdown.trim() ?? \"\"}`);\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return {\n title: null,\n markdown,\n text_content: markdown\n };\n }\n}\n\nfunction sheetToHtml(rows: SheetData): string {\n const columnCount = rows.reduce((max, row) => Math.max(max, row.length), 0);\n if (!columnCount || rows.length === 0) {\n return \"\";\n }\n\n const htmlRows = rows.map((row) => {\n const cells: string[] = [];\n for (let column = 0; column < columnCount; column++) {\n cells.push(`<td>${escapeHtml(cellText(row[column]))}</td>`);\n }\n return `<tr>${cells.join(\"\")}</tr>`;\n });\n\n return `<html><body><table>${htmlRows.join(\"\")}</table></body></html>`;\n}\n\nfunction cellText(value: unknown): string {\n if (value == null) {\n return \"\";\n }\n if (value instanceof Date) {\n return value.toISOString();\n }\n return String(value);\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n","import type { Document, Element } from \"@xmldom/xmldom\";\nimport { DOMParser } from \"@xmldom/xmldom\";\nimport { decodeText } from \"../bytes\";\nimport { CustomTurnDown } from \"../custom-turndown\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class RSSConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (![\".xml\", \".rss\", \".atom\"].includes(extension)) {\n return null;\n }\n\n const document = new DOMParser().parseFromString(decodeText(source), \"text/xml\");\n if (document.getElementsByTagName(\"rss\").length > 0) {\n return this.parseRss(document);\n }\n if (document.getElementsByTagName(\"feed\")[0]?.getElementsByTagName(\"entry\").length) {\n return this.parseAtom(document);\n }\n return null;\n }\n\n private parseAtom(document: Document): ConverterResult {\n const root = document.getElementsByTagName(\"feed\")[0];\n if (!root) return null;\n\n const title = getText(root, \"title\");\n const subtitle = getText(root, \"subtitle\");\n const sections = [`# ${title ?? \"Feed\"}`];\n if (subtitle) sections.push(subtitle);\n\n for (const entry of [...root.getElementsByTagName(\"entry\")]) {\n const entryTitle = getText(entry, \"title\");\n const updated = getText(entry, \"updated\");\n const summary = getText(entry, \"summary\");\n const content = getText(entry, \"content\");\n const lines: string[] = [];\n if (entryTitle) lines.push(`## ${entryTitle}`);\n if (updated) lines.push(`Updated on: ${updated}`);\n if (summary) lines.push(parseContent(summary));\n if (content) lines.push(parseContent(content));\n sections.push(lines.join(\"\\n\"));\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n\n private parseRss(document: Document): ConverterResult {\n const channel = document.getElementsByTagName(\"rss\")[0]?.getElementsByTagName(\"channel\")[0];\n if (!channel) return null;\n\n const title = getText(channel, \"title\");\n const description = getText(channel, \"description\");\n const sections: string[] = title ? [`# ${title}`] : [];\n if (description) sections.push(description);\n\n for (const item of [...channel.getElementsByTagName(\"item\")]) {\n const itemTitle = getText(item, \"title\");\n const published = getText(item, \"pubDate\");\n const itemDescription = getText(item, \"description\");\n const content = getText(item, \"content:encoded\");\n const lines: string[] = [];\n if (itemTitle) lines.push(`## ${itemTitle}`);\n if (published) lines.push(`Published on: ${published}`);\n if (itemDescription) lines.push(parseContent(itemDescription));\n if (content) lines.push(parseContent(content));\n sections.push(lines.join(\"\\n\"));\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n\nfunction parseContent(content: string): string {\n return new CustomTurnDown().convertSoup(parseHtmlDocument(content).documentElement);\n}\n\nfunction getText(element: Element, tagName: string): string | null {\n const node = element.getElementsByTagName(tagName)[0];\n return node?.textContent?.trim() || null;\n}\n","import { decodeText } from \"../bytes\";\nimport { parseHtmlDocument } from \"../html-document\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class YouTubeConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n const extension = options.file_extension?.toLowerCase() ?? \"\";\n if (\n (extension !== \".html\" && extension !== \".htm\") ||\n !options.url?.startsWith(\"https://www.youtube.com/watch?\")\n ) {\n return null;\n }\n\n const document = parseHtmlDocument(decodeText(source));\n const metadata: Record<string, string> = { title: document.title };\n\n document.querySelectorAll(\"meta\").forEach((meta) => {\n const content = meta.getAttribute(\"content\");\n const key =\n meta.getAttribute(\"itemprop\") ?? meta.getAttribute(\"property\") ?? meta.getAttribute(\"name\");\n if (key && content) {\n metadata[key] = content;\n }\n });\n\n try {\n for (const script of document.querySelectorAll(\"script\")) {\n const content = script.textContent ?? \"\";\n if (!content.includes(\"ytInitialData\")) {\n continue;\n }\n const start = content.indexOf(\"{\");\n const end = content.lastIndexOf(\"}\");\n if (start >= 0 && end > start) {\n const description = findKey(\n JSON.parse(content.slice(start, end + 1)),\n \"attributedDescriptionBodyText\"\n );\n if (isRecord(description) && typeof description.content === \"string\") {\n metadata.description = description.content;\n }\n }\n break;\n }\n } catch {\n // Meta description remains available when the page implementation changes.\n }\n\n const title = first(metadata, [\"title\", \"og:title\", \"name\"]) || document.title || null;\n const lines = [\"# YouTube\"];\n if (title) {\n lines.push(`## ${title}`);\n }\n\n const stats: string[] = [];\n const views = first(metadata, [\"interactionCount\"]);\n const keywords = first(metadata, [\"keywords\"]);\n const runtime = first(metadata, [\"duration\"]);\n if (views) stats.push(`- **Views:** ${views}`);\n if (keywords) stats.push(`- **Keywords:** ${keywords}`);\n if (runtime) stats.push(`- **Runtime:** ${runtime}`);\n if (stats.length > 0) {\n lines.push(`### Video Metadata\\n${stats.join(\"\\n\")}`);\n }\n\n const description = first(metadata, [\"description\", \"og:description\"]);\n if (description) {\n lines.push(`### Description\\n${description}`);\n }\n\n const markdown = lines.join(\"\\n\\n\");\n return { title, markdown, text_content: markdown };\n }\n}\n\nfunction first(metadata: Record<string, string>, keys: string[]): string | null {\n for (const key of keys) {\n if (metadata[key]) return metadata[key];\n }\n return null;\n}\n\nfunction findKey(value: unknown, key: string): unknown {\n if (Array.isArray(value)) {\n for (const item of value) {\n const match = findKey(item, key);\n if (match !== undefined) return match;\n }\n } else if (isRecord(value)) {\n if (key in value) return value[key];\n for (const item of Object.values(value)) {\n const match = findKey(item, key);\n if (match !== undefined) return match;\n }\n }\n return undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n","import { unzipSync } from \"fflate\";\nimport { extensionFromPathname } from \"../mime\";\nimport type { ConverterOptions, ConverterResult, DocumentConverter } from \"../types\";\n\nexport class ZipConverter implements DocumentConverter {\n async convert(source: Uint8Array, options: ConverterOptions = {}): Promise<ConverterResult> {\n if (options.file_extension?.toLowerCase() !== \".zip\") {\n return null;\n }\n\n const files = unzipSync(source, {\n filter: (file) => !file.name.endsWith(\"/\")\n });\n const converters = options._parent_converters ?? [];\n const zipName = options.url ?? \"archive.zip\";\n const sections = [`Content from the zip file \\`${zipName}\\`:`];\n\n for (const [name, bytes] of Object.entries(files)) {\n const result = await convertEntry(bytes, name, converters, options);\n if (result) {\n sections.push(`## File: ${name}\\n\\n${result.markdown}`);\n }\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return { title: null, markdown, text_content: markdown };\n }\n}\n\nasync function convertEntry(\n source: Uint8Array,\n name: string,\n converters: DocumentConverter[],\n options: ConverterOptions\n): Promise<ConverterResult> {\n const extension = extensionFromPathname(name);\n if (!extension) {\n return null;\n }\n\n const entryOptions: ConverterOptions = {\n ...options,\n file_extension: extension,\n url: undefined,\n _parent_converters: converters\n };\n\n for (const converter of converters) {\n try {\n const result = await converter.convert(source, entryOptions);\n if (result) {\n return result;\n }\n } catch {\n // Match the original ZipConverter: skip entries that fail conversion.\n }\n }\n\n return null;\n}\n","import { isBlob, toUint8Array } from \"./bytes\";\nimport { BingSerpConverter } from \"./converters/bingserp\";\nimport { DocxConverter } from \"./converters/docx\";\nimport { HtmlConverter } from \"./converters/html\";\nimport { IpynbConverter } from \"./converters/ipynb\";\nimport { PdfConverter } from \"./converters/pdf\";\nimport { PlainTextConverter } from \"./converters/plain-text\";\nimport { PptxConverter } from \"./converters/pptx\";\nimport { WikipediaConverter } from \"./converters/wikipedia\";\nimport { XlsxConverter } from \"./converters/xlsx\";\nimport { RSSConverter } from \"./converters/xml-rss-atom\";\nimport { YouTubeConverter } from \"./converters/youtube\";\nimport { ZipConverter } from \"./converters/zip\";\nimport { extensionFromMime, extensionFromPathname } from \"./mime\";\nimport type { ByteSource, ConverterOptions, ConverterResult, DocumentConverter } from \"./types\";\n\nexport type ConversionSource = ByteSource | Response | URL | string;\n\nexport class MarkItDown {\n private readonly converters: DocumentConverter[] = [];\n\n constructor() {\n this.registerConverter(new PlainTextConverter());\n this.registerConverter(new HtmlConverter());\n this.registerConverter(new ZipConverter());\n this.registerConverter(new RSSConverter());\n this.registerConverter(new WikipediaConverter());\n this.registerConverter(new YouTubeConverter());\n this.registerConverter(new BingSerpConverter());\n this.registerConverter(new DocxConverter());\n this.registerConverter(new XlsxConverter());\n this.registerConverter(new PptxConverter());\n this.registerConverter(new PdfConverter());\n this.registerConverter(new IpynbConverter());\n }\n\n /** Convert a URL, response, blob, array buffer, data view, or typed array. */\n async convert(\n source: ConversionSource,\n options: ConverterOptions = {}\n ): Promise<ConverterResult> {\n if (typeof source === \"string\" || source instanceof URL) {\n return this.convertUrl(source.toString(), options);\n }\n\n if (isResponse(source)) {\n return this.convertResponse(source, options);\n }\n\n const extensions = new Set<string>();\n this.addExtension(extensions, options.file_extension?.replace(/^\\./, \"\"));\n\n if (isBlob(source)) {\n this.addExtension(extensions, extensionFromMime(source.type));\n if (\"name\" in source && typeof source.name === \"string\") {\n this.addExtension(extensions, extensionFromPathname(source.name));\n }\n }\n\n if (extensions.size === 0) {\n throw new Error(\n \"Could not determine the file type. Provide `file_extension` when converting bytes.\"\n );\n }\n\n return this.convertBytes(await toUint8Array(source), extensions, options);\n }\n\n /**\n * @deprecated Pass the byte source directly to `convert`.\n */\n async convertBuffer(\n source: ByteSource,\n options: ConverterOptions & { file_extension: string }\n ): Promise<ConverterResult> {\n return this.convert(source, options);\n }\n\n private async convertUrl(\n source: string,\n { fetch: fetchImplementation = globalThis.fetch, ...options }: ConverterOptions\n ): Promise<ConverterResult> {\n const url = new URL(source);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new Error(`Unsupported URL protocol: ${url.protocol}`);\n }\n if (!fetchImplementation) {\n throw new Error(\"No fetch implementation is available.\");\n }\n\n const response = await fetchImplementation(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch URL: ${url}, status: ${response.status}`);\n }\n\n return this.convertResponse(response, { ...options, url: url.toString() });\n }\n\n private async convertResponse(\n response: Response,\n options: ConverterOptions\n ): Promise<ConverterResult> {\n const extensions = new Set<string>();\n this.addExtension(extensions, options.file_extension);\n this.addExtension(extensions, extensionFromMime(response.headers.get(\"content-type\")));\n\n const disposition = response.headers.get(\"content-disposition\") ?? \"\";\n const filename = disposition.match(/filename\\*?=(?:UTF-8''|[\"']?)([^;\"']+)/i)?.[1];\n if (filename) {\n this.addExtension(extensions, extensionFromPathname(decodeURIComponent(filename.trim())));\n }\n\n const responseUrl = options.url || response.url;\n if (responseUrl) {\n this.addExtension(extensions, extensionFromPathname(new URL(responseUrl).pathname));\n }\n\n if (extensions.size === 0) {\n throw new Error(\n \"Could not determine the file type. Provide `file_extension` or a Content-Type header.\"\n );\n }\n\n return this.convertBytes(new Uint8Array(await response.arrayBuffer()), extensions, {\n ...options,\n url: responseUrl\n });\n }\n\n private async convertBytes(\n source: Uint8Array,\n extensions: Set<string>,\n options: ConverterOptions\n ): Promise<ConverterResult> {\n let lastError: unknown;\n\n for (const extension of extensions) {\n for (const converter of this.converters) {\n try {\n const result = await converter.convert(source, {\n ...options,\n file_extension: extension,\n _parent_converters: this.converters\n });\n if (result) {\n result.markdown = result.markdown\n .replace(/\\r\\n|\\r|\\n/g, \"\\n\")\n .trim()\n .replace(/\\n{3,}/g, \"\\n\\n\");\n result.text_content = result.markdown;\n return result;\n }\n } catch (error) {\n if (options.debug) {\n console.error(\"Converter threw error:\", error);\n }\n lastError = error;\n }\n }\n }\n\n const formats = [...extensions].join(\", \");\n if (lastError) {\n throw new Error(`Could not convert ${formats} to Markdown: ${String(lastError)}`);\n }\n throw new Error(`Unsupported file type: ${formats}.`);\n }\n\n private addExtension(extensions: Set<string>, extension: string | null | undefined): void {\n if (!extension) {\n return;\n }\n extensions.add(\n extension.startsWith(\".\") ? extension.toLowerCase() : `.${extension.toLowerCase()}`\n );\n }\n\n private registerConverter(converter: DocumentConverter): void {\n this.converters.unshift(converter);\n }\n}\n\nfunction isResponse(value: unknown): value is Response {\n return typeof Response !== \"undefined\" && value instanceof Response;\n}\n"],"mappings":";;;;;;;;;;AAEA,eAAsB,aAAa,QAAyC;CAC1E,IAAI,kBAAkB,YACpB,OAAO;CAGT,IAAI,OAAO,MAAM,GACf,OAAO,IAAI,WAAW,MAAM,OAAO,YAAY,CAAC;CAGlD,IAAI,YAAY,OAAO,MAAM,GAC3B,OAAO,IAAI,WAAW,OAAO,QAAQ,OAAO,YAAY,OAAO,UAAU;CAG3E,OAAO,IAAI,WAAW,MAAM;AAC9B;AAEA,SAAgB,cAAc,QAAiC;CAC7D,OAAO,OAAO,MAAM,CAAC,CAAC;AACxB;AAEA,SAAgB,WAAW,QAA4B;CACrD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM;AACxC;AAEA,SAAgB,OAAO,OAA+B;CACpD,OAAO,OAAO,SAAS,eAAe,iBAAiB;AACzD;;;ACzBA,IAAa,iBAAb,MAA4B;CAC1B,YAAY,UAAiC;EAC3C,MAAM,UAAU,IAAI,gBAAgB,EAAE,cAAc,MAAM,CAAC;EAC3D,QAAQ,IAAI,kBAAkB,GAAG;EAEjC,QAAQ,QAAQ,eAAe;GAC7B,QAAQ,CAAC,GAAG;GACZ,YAAY,SAAS,MAAM;IACzB,IAAI,CAAC,SAAS,OAAO;IAErB,MAAM,SAAS,QAAQ,WAAW,GAAG,IAAI,MAAM;I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,QACA,YACA,SAC0B;EAC1B,IAAI;EAEJ,KAAK,MAAM,aAAa,YACtB,KAAK,MAAM,aAAa,KAAK,YAC3B,IAAI;GACF,MAAM,SAAS,MAAM,UAAU,QAAQ,QAAQ;IAC7C,GAAG;IACH,gBAAgB;IAChB,oBAAoB,KAAK;GAC3B,CAAC;GACD,IAAI,QAAQ;IACV,OAAO,WAAW,OAAO,SACtB,QAAQ,eAAe,IAAI,CAAC,CAC5B,KAAK,CAAC,CACN,QAAQ,WAAW,MAAM;IAC5B,OAAO,eAAe,OAAO;IAC7B,OAAO;GACT;EACF,SAAS,OAAO;GACd,IAAI,QAAQ,OACV,QAAQ,MAAM,0BAA0B,KAAK;GAE/C,YAAY;EACd;EAIJ,MAAM,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC,KAAK,IAAI;EACzC,IAAI,WACF,MAAM,IAAI,MAAM,qBAAqB,QAAQ,gBAAgB,OAAO,SAAS,GAAG;EAElF,MAAM,IAAI,MAAM,0BAA0B,QAAQ,EAAE;CACtD;CAEA,aAAqB,YAAyB,WAA4C;EACxF,IAAI,CAAC,WACH;EAEF,WAAW,IACT,UAAU,WAAW,GAAG,IAAI,UAAU,YAAY,IAAI,IAAI,UAAU,YAAY,GAClF;CACF;CAEA,kBAA0B,WAAoC;EAC5D,KAAK,WAAW,QAAQ,SAAS;CACnC;AACF;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,aAAa,eAAe,iBAAiB;AAC7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryangarber/markitdown-ts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Convert various file formats to Markdown for indexing, text analysis, and other applications that benefit from structured text. Node-free fork of the TypeScript fork of the original Python library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"docx",
|
|
11
11
|
"pdf",
|
|
12
12
|
"xlsx",
|
|
13
|
+
"pptx",
|
|
13
14
|
"zip"
|
|
14
15
|
],
|
|
15
16
|
"homepage": "https://github.com/ryangarber/markitdown-ts#readme",
|
|
@@ -56,11 +57,12 @@
|
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@commander-js/extra-typings": "^15.0.0",
|
|
58
59
|
"@joplin/turndown-plugin-gfm": "^1.0.67",
|
|
60
|
+
"@jvmr/pptx-to-html": "^1.1.1",
|
|
59
61
|
"@xmldom/xmldom": "^0.9.11",
|
|
60
|
-
"exceljs": "^4.4.0",
|
|
61
62
|
"fflate": "^0.8.3",
|
|
62
63
|
"linkedom": "^0.18.13",
|
|
63
64
|
"mammoth": "^1.12.1",
|
|
65
|
+
"read-excel-file": "^9.3.10",
|
|
64
66
|
"turndown": "^7.2.4",
|
|
65
67
|
"unpdf": "^1.8.1"
|
|
66
68
|
},
|