/reamkit:documents-to-markdownfrom reamkit
Extracts text from Word, Excel, PowerPoint, and PDF files as GitHub-Flavored Markdown using Ream. Handles pictures, slides, sheets, and scanned PDFs for LLM prompts, RAG, or search indexing.
Ships in reamkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
convert('md') writes GitHub-Flavored Markdown from any of the seven input
formats. It needs no fonts and no layout, so it does no network or file I/O and
runs equally in the page (before anything is uploaded), a worker, or a server.
npm install reamkit
import { Ream } from 'reamkit';
/** An attached document as Markdown a model can read, whatever its format. */
export async function attachmentToMarkdown(bytes: Uint8Array): Promise<string> {
const doc = Ream.parse(bytes); // .docx .xlsx .pptx .pdf .doc .xls .ppt, sniffed
const deck = doc.format === 'pptx' || doc.format === 'ppt';
const md = await doc.convert('md', {
images: 'drop', // no base64 pictures in the prompt
pageBreaks: deck ? 'rule' : 'drop', // a deck's slides apart by ---
});
return new TextDecoder().decode(md);
}
bytes must be a Uint8Array (new Uint8Array(await file.arrayBuffer())).
For encrypted input, pass { password } to Ream.parse and catch
WrongPasswordError; the convert-documents skill covers that flow.
.docx, .doc): headings, paragraphs, lists with their real
numbers and nesting, GFM tables, links, footnotes and the text inside shapes..xlsx, .xls): one # <tab name> heading per sheet, then its
grid as a table, each cell's text in its own column.
{ sheetNames: false } leaves out the headings..pptx, .ppt): each slide's text in order. Slides are
separated only when pageBreaks: 'rule' asks for a --- between them; by
default the breaks are dropped and the slides run together.images | Output | Use for |
|---|---|---|
'dataUri' (default) | Each picture inlined as a base64 data: URI | One self-contained file for a viewer |
'drop' | No pictures | Model prompts, embeddings, search |
'link' | Image references to media/image1.png, media/image2.jpg, … under ./, numbered in order of first use | A caller that writes the image files itself |
With 'link' the writer does not write the image bytes anywhere and records a
degraded images loss saying so; convert returns only the Markdown.
const doc = Ream.parse(bytes);
const text = new TextDecoder().decode(
await doc.convert('md', { images: 'drop', pageBreaks: 'rule' }),
);
const chunks =
doc.format === 'pptx' || doc.format === 'ppt'
? text.split(/^---$/mu) // one chunk per slide
: doc.format === 'xlsx' || doc.format === 'xls'
? text.split(/^(?=# )/mu) // one chunk per sheet heading
: [text];
Markdown has no syntax for alignment, merged cells, charts, math, headers and footers. Each kind of omission is reported once, however often it occurs:
const { bytes: md, losses } = await Ream.parse(bytes).convertWithReport('md', { images: 'drop' });
for (const loss of losses) console.log(loss.severity, loss.feature, loss.detail);
Pass the report to whoever needs to know (for example "the document's charts
were not included"); do not use strict: true here, which throws on the first
of these ordinary omissions.
A scanned PDF without a text layer, or a deck of pictures, converts without an error to Markdown with no words in it. Check before sending it on:
const markdown = await attachmentToMarkdown(bytes);
if (!/\p{L}|\p{N}/u.test(markdown)) {
// nothing to read: ask for a text version, or run OCR before Ream
}
The default images: 'dataUri' embeds every picture as base64. One photo can
outweigh the whole text in tokens and tells a text model nothing. Pass
images: 'drop' for model input and indexing. Source: MarkdownWriteOptions
in src/markdown/markdown-writer.ts.
Without pageBreaks: 'rule', the slides of a .pptx or .ppt run together
with nothing between them, and the page-break loss is all that remains of the
boundaries. Ask for the rule when the slide structure matters. Source:
docs/src/content/docs/guides/examples.md.
Ream reads a PDF's text, not its pictures; a scan gives text only where OCR software left a text layer under the image. Detect the empty result (above) rather than handing the model an empty document.
PDF and SVG need fonts and may download them; HTML carries markup and inline
styles. For text, md is the narrowest target and the one that never needs the
network.
#
lines and tables as | rows where the source had them.pageBreaks: 'rule', the number of --- separators is the
number of slides minus one.images: 'drop' was passed.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
document-conversion, markdown, pdf-extraction, office-files, rag
4 skills in this plugin
/convert-documentsUse when converting Word, Excel, PowerPoint or PDF files (.docx, .xlsx, .pptx, .pdf and legacy .doc, .xls, .ppt) to PDF, SVG, HTML, Markdown, DOCX or XLSX with reamkit (Ream) in a browser, Node.js, serverless or edge runtime: reading the bytes, choosing a target, opening a password-protected file, reading a PDF back as an editable document, and checking what the conversion lost.
/pdf-complianceUse when producing archival PDF/A (1a/1b, 2a/2b/2u, 3a/3b/3u), accessible PDF/UA-1 or tagged PDF, digitally signed, password-encrypted or bookmarked PDF with reamkit (Ream), embedding the source file or other attachments, setting PDF metadata, or matching Word's or LibreOffice's pagination.
/supply-fontsUse when a reamkit (Ream) PDF or SVG conversion has to run without network access (offline, air-gapped, a serverless function without egress, a strict Content-Security-Policy), must use the organisation's own typefaces or the fonts installed on the user's machine, or comes out with empty boxes, the wrong typeface or a font loss in its report. Not needed for HTML, Markdown, DOCX or XLSX output, which use no fonts.
npx claudepluginhub alex-krassavin/reamkit --plugin reamkitOther plugins' skills for the same job