@ryangarber/markitdown-ts 0.1.1 → 0.1.3
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/LICENSE +1 -0
- package/README.md +9 -13
- package/dist/index.cjs +27 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# markitdown-ts
|
|
2
2
|
|
|
3
|
-
`markitdown-ts` converts
|
|
3
|
+
`markitdown-ts` converts various file types to Markdown without filesystem, process, stream, or any other runtime-specific dependencies. It can run in browsers, workers, edge functions, and all other modern JavaScript environments.
|
|
4
4
|
|
|
5
5
|
## Supported formats
|
|
6
6
|
|
|
@@ -14,23 +14,21 @@
|
|
|
14
14
|
- ZIP archives (`.zip`), with nested files converted recursively
|
|
15
15
|
- Wikipedia, YouTube metadata, and Bing result pages supplied as HTML
|
|
16
16
|
|
|
17
|
-
Audio, image metadata, local-path, and YouTube transcript features from the original project are intentionally
|
|
18
|
-
They may be added back over time as alternative implementations are found. Want to see one added? Contributions are welcome!
|
|
17
|
+
Audio, image metadata, local-path, and YouTube transcript features from the original project are intentionally left out because their implementations depended on runtime-specific modules, binaries, streams, or filesystem access. They may be added back over time as alternative implementations are found. Want to see one added? Contributions are welcome!
|
|
19
18
|
|
|
20
19
|
## Installation
|
|
21
20
|
|
|
22
21
|
```sh
|
|
23
|
-
|
|
22
|
+
pnpm install @ryangarber/markitdown-ts
|
|
24
23
|
```
|
|
25
24
|
|
|
26
25
|
## Usage
|
|
27
26
|
|
|
28
|
-
### `Uint8Array` (preferred)
|
|
29
|
-
|
|
30
27
|
```ts
|
|
31
|
-
import { MarkItDown } from "markitdown-ts";
|
|
28
|
+
import { MarkItDown } from "@ryangarber/markitdown-ts";
|
|
29
|
+
|
|
30
|
+
const bytes: Uint8Array = /* plain bytes */;
|
|
32
31
|
|
|
33
|
-
const bytes = new TextEncoder().encode("Hello from the web");
|
|
34
32
|
const result = await new MarkItDown().convert(bytes, {
|
|
35
33
|
file_extension: ".txt"
|
|
36
34
|
});
|
|
@@ -38,14 +36,11 @@ const result = await new MarkItDown().convert(bytes, {
|
|
|
38
36
|
console.log(result?.markdown);
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
Any `Uint8Array` subclass is accepted as well. This keeps byte data from other modern JavaScript runtimes interoperable without requiring runtime-specific types.
|
|
42
|
-
|
|
43
|
-
### Other in-memory sources
|
|
44
|
-
|
|
45
39
|
The same `convert` method accepts:
|
|
46
40
|
|
|
41
|
+
- `Uint8Array`
|
|
47
42
|
- `ArrayBuffer` and `SharedArrayBuffer`
|
|
48
|
-
-
|
|
43
|
+
- `DataView` or any other typed array
|
|
49
44
|
- `Blob` and `File`
|
|
50
45
|
- `Response`
|
|
51
46
|
|
|
@@ -105,4 +100,5 @@ Biome handles both formatting and linting. `tsup` produces ESM, CommonJS, source
|
|
|
105
100
|
|
|
106
101
|
## License
|
|
107
102
|
|
|
103
|
+
MIT License © 2026 Ryan Garber\
|
|
108
104
|
MIT License © 2024 Vaibhav Raj
|
package/dist/index.cjs
CHANGED
|
@@ -29,8 +29,7 @@ let linkedom = require("linkedom");
|
|
|
29
29
|
let mammoth = require("mammoth");
|
|
30
30
|
mammoth = __toESM(mammoth, 1);
|
|
31
31
|
let unpdf = require("unpdf");
|
|
32
|
-
let
|
|
33
|
-
xlsx = __toESM(xlsx, 1);
|
|
32
|
+
let exceljs = require("exceljs");
|
|
34
33
|
let _xmldom_xmldom = require("@xmldom/xmldom");
|
|
35
34
|
let fflate = require("fflate");
|
|
36
35
|
//#region src/bytes.ts
|
|
@@ -308,23 +307,41 @@ var WikipediaConverter = class {
|
|
|
308
307
|
var XlsxConverter = class extends HtmlConverter {
|
|
309
308
|
async convert(source, options) {
|
|
310
309
|
if (options.file_extension?.toLowerCase() !== ".xlsx") return null;
|
|
311
|
-
const workbook =
|
|
310
|
+
const workbook = new exceljs.Workbook();
|
|
311
|
+
await workbook.xlsx.load(toArrayBuffer(source));
|
|
312
312
|
const sections = [];
|
|
313
|
-
for (const
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
313
|
+
for (const worksheet of workbook.worksheets) {
|
|
314
|
+
const html = worksheetToHtml(worksheet);
|
|
315
|
+
if (!html) continue;
|
|
316
|
+
const result = await this.convertHtml(html);
|
|
317
|
+
sections.push(`## ${worksheet.name}\n${result?.markdown.trim() ?? ""}`);
|
|
319
318
|
}
|
|
320
319
|
const markdown = sections.join("\n\n");
|
|
321
320
|
return {
|
|
322
|
-
title: workbook.
|
|
321
|
+
title: workbook.title || "Untitled",
|
|
323
322
|
markdown,
|
|
324
323
|
text_content: markdown
|
|
325
324
|
};
|
|
326
325
|
}
|
|
327
326
|
};
|
|
327
|
+
function worksheetToHtml(worksheet) {
|
|
328
|
+
const columnCount = worksheet.columnCount;
|
|
329
|
+
if (!columnCount || !worksheet.actualRowCount) return "";
|
|
330
|
+
const rows = [];
|
|
331
|
+
worksheet.eachRow({ includeEmpty: true }, (row) => {
|
|
332
|
+
const cells = [];
|
|
333
|
+
for (let column = 1; column <= columnCount; column++) cells.push(`<td>${escapeHtml(cellText(row.getCell(column)))}</td>`);
|
|
334
|
+
rows.push(`<tr>${cells.join("")}</tr>`);
|
|
335
|
+
});
|
|
336
|
+
return `<html><body><table>${rows.join("")}</table></body></html>`;
|
|
337
|
+
}
|
|
338
|
+
function cellText(cell) {
|
|
339
|
+
if (cell.isMerged && cell.master !== cell) return "";
|
|
340
|
+
return cell.text;
|
|
341
|
+
}
|
|
342
|
+
function escapeHtml(value) {
|
|
343
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
344
|
+
}
|
|
328
345
|
//#endregion
|
|
329
346
|
//#region src/converters/xml-rss-atom.ts
|
|
330
347
|
var RSSConverter = class {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["TurndownService","turndownPluginGfm","parseHTML","getDocumentProxy","extractText","getMeta","XLSX","DOMParser","unzipSync"],"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 document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document.body ?? document);\n return {\n title: document.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 const html = await mammoth.convertToHtml(\n { arrayBuffer: toArrayBuffer(source) },\n {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix,\n transformDocument: options.transformDocument\n }\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 * as XLSX from \"xlsx\";\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 workbook = XLSX.read(source, { type: \"array\" });\n const sections: string[] = [];\n\n for (const sheetName of workbook.SheetNames) {\n const sheet = workbook.Sheets[sheetName];\n if (sheet?.[\"!ref\"]) {\n const result = await this.convertHtml(XLSX.utils.sheet_to_html(sheet));\n sections.push(`## ${sheetName}\\n${result?.markdown.trim() ?? \"\"}`);\n }\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return {\n title: workbook.Props?.Title || \"Untitled\",\n markdown,\n text_content: markdown\n };\n }\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);\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 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,IAAIA,SAAAA,QAAgB,EAAE,cAAc,MAAM,CAAC;EAC3D,QAAQ,IAAIC,4BAAAA,QAAkB,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;IAC/C,MAAM,SAAS,QAAQ,SAAS,GAAG,IAAI,MAAM;IAC7C,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,WAAW,EAAE;IACjD,IAAI,CAAC,MAAM,OAAO;IAElB,MAAM,UAAU;IAChB,MAAM,OAAO,QAAQ,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,kBAA0B,WAAoC;EAC5D,KAAK,WAAW,QAAQ,SAAS;CACnC;AACF;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,aAAa,eAAe,iBAAiB;AAC7D"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["TurndownService","turndownPluginGfm","parseHTML","getDocumentProxy","extractText","getMeta","Workbook","DOMParser","unzipSync"],"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 document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document.body ?? document);\n return {\n title: document.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 const html = await mammoth.convertToHtml(\n { arrayBuffer: toArrayBuffer(source) },\n {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix,\n transformDocument: options.transformDocument\n }\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 { type Cell, Workbook, type Worksheet } from \"exceljs\";\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 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);\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 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,IAA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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/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
import { Workbook } from "exceljs";
|
|
7
7
|
import { DOMParser } from "@xmldom/xmldom";
|
|
8
8
|
import { unzipSync } from "fflate";
|
|
9
9
|
//#region src/bytes.ts
|
|
@@ -281,23 +281,41 @@ var WikipediaConverter = class {
|
|
|
281
281
|
var XlsxConverter = class extends HtmlConverter {
|
|
282
282
|
async convert(source, options) {
|
|
283
283
|
if (options.file_extension?.toLowerCase() !== ".xlsx") return null;
|
|
284
|
-
const workbook =
|
|
284
|
+
const workbook = new Workbook();
|
|
285
|
+
await workbook.xlsx.load(toArrayBuffer(source));
|
|
285
286
|
const sections = [];
|
|
286
|
-
for (const
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
287
|
+
for (const worksheet of workbook.worksheets) {
|
|
288
|
+
const html = worksheetToHtml(worksheet);
|
|
289
|
+
if (!html) continue;
|
|
290
|
+
const result = await this.convertHtml(html);
|
|
291
|
+
sections.push(`## ${worksheet.name}\n${result?.markdown.trim() ?? ""}`);
|
|
292
292
|
}
|
|
293
293
|
const markdown = sections.join("\n\n");
|
|
294
294
|
return {
|
|
295
|
-
title: workbook.
|
|
295
|
+
title: workbook.title || "Untitled",
|
|
296
296
|
markdown,
|
|
297
297
|
text_content: markdown
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
|
+
function worksheetToHtml(worksheet) {
|
|
302
|
+
const columnCount = worksheet.columnCount;
|
|
303
|
+
if (!columnCount || !worksheet.actualRowCount) return "";
|
|
304
|
+
const rows = [];
|
|
305
|
+
worksheet.eachRow({ includeEmpty: true }, (row) => {
|
|
306
|
+
const cells = [];
|
|
307
|
+
for (let column = 1; column <= columnCount; column++) cells.push(`<td>${escapeHtml(cellText(row.getCell(column)))}</td>`);
|
|
308
|
+
rows.push(`<tr>${cells.join("")}</tr>`);
|
|
309
|
+
});
|
|
310
|
+
return `<html><body><table>${rows.join("")}</table></body></html>`;
|
|
311
|
+
}
|
|
312
|
+
function cellText(cell) {
|
|
313
|
+
if (cell.isMerged && cell.master !== cell) return "";
|
|
314
|
+
return cell.text;
|
|
315
|
+
}
|
|
316
|
+
function escapeHtml(value) {
|
|
317
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
318
|
+
}
|
|
301
319
|
//#endregion
|
|
302
320
|
//#region src/converters/xml-rss-atom.ts
|
|
303
321
|
var RSSConverter = class {
|
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 document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document.body ?? document);\n return {\n title: document.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 const html = await mammoth.convertToHtml(\n { arrayBuffer: toArrayBuffer(source) },\n {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix,\n transformDocument: options.transformDocument\n }\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 * as XLSX from \"xlsx\";\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 workbook = XLSX.read(source, { type: \"array\" });\n const sections: string[] = [];\n\n for (const sheetName of workbook.SheetNames) {\n const sheet = workbook.Sheets[sheetName];\n if (sheet?.[\"!ref\"]) {\n const result = await this.convertHtml(XLSX.utils.sheet_to_html(sheet));\n sections.push(`## ${sheetName}\\n${result?.markdown.trim() ?? \"\"}`);\n }\n }\n\n const markdown = sections.join(\"\\n\\n\");\n return {\n title: workbook.Props?.Title || \"Untitled\",\n markdown,\n text_content: markdown\n };\n }\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);\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 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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AC,CACN,QAAQ,WAAW,MAAM;IAC5B,OAAO,eAAe,OAAO;IAC7B,OAAO;GACT;EACF,SAAS,OAAO;GACd,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"}
|
|
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 document.querySelectorAll(\"script, style\").forEach((element) => {\n element.remove();\n });\n\n const markdown = new CustomTurnDown().convertSoup(document.body ?? document);\n return {\n title: document.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 const html = await mammoth.convertToHtml(\n { arrayBuffer: toArrayBuffer(source) },\n {\n styleMap: options.styleMap,\n includeEmbeddedStyleMap: options.includeEmbeddedStyleMap,\n includeDefaultStyleMap: options.includeDefaultStyleMap,\n ignoreEmptyParagraphs: options.ignoreEmptyParagraphs,\n idPrefix: options.idPrefix,\n transformDocument: options.transformDocument\n }\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 { type Cell, Workbook, type Worksheet } from \"exceljs\";\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 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);\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 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,k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zC,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.3",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"mammoth": "^1.12.1",
|
|
59
59
|
"turndown": "^7.2.4",
|
|
60
60
|
"unpdf": "^1.8.1",
|
|
61
|
-
"
|
|
61
|
+
"exceljs": "^4.4.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@biomejs/biome": "^2.5.9",
|