Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { ExtractionResult } from "@kreuzberg/wasm";
import { extractBytes, initWasm } from "@kreuzberg/wasm";
class MarkdownFormatter {
async process(result: ExtractionResult): Promise<ExtractionResult> {
const formatted = result.content.replace(/^(.+)$/gm, "# $1").replace(/\n\n+/g, "\n\n");
return {
...result,
content: formatted,
};
}
getName(): string {
return "markdown-formatter";
}
getVersion(): string {
return "1.0.0";
}
}
async function demonstrateCustomProcessor() {
await initWasm();
const processor = new MarkdownFormatter();
const bytes = new Uint8Array(await fetch("document.pdf").then((r) => r.arrayBuffer()));
let result = await extractBytes(bytes, "application/pdf");
result = await processor.process(result);
console.log("Formatted result:", result.content);
return result;
}
demonstrateCustomProcessor().catch(console.error);