Skip to content

feat: Read Word, PowerPoint and Excel files natively - #53

Merged
DeepanshuMishraa merged 4 commits into
mainfrom
feat/office-documents
Nov 19, 2026
Merged

DeepanshuMishraa merged 4 commits into
mainfrom
feat/office-documents

Conversation

@DeepanshuMishraa

@DeepanshuMishraa DeepanshuMishraa commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Opens office files without LibreOffice, Keynote, Pages or Numbers. leaf reads the zip/XML itself, so it works the same on macOS and Linux and opens in milliseconds.

What opens

  • Decks (.pptx, .pptm, .ppsx, .potx…): each slide drawn from its master, layout and theme, with shapes, pictures, fonts, tables, charts and SmartArt. Speaker notes sit beneath.
  • Word (.docx, .docm, .dotx…): styles, lists, tables, pictures and fields laid out on the document's page size and margins.
  • Spreadsheets (.xlsx, .xlsm, .xlsb, .xls, .ods, .csv, .tsv): a real grid with column letters and row numbers. .xlsx brings cell fonts, fills, borders, alignment, column widths and row heights.

Looks

  • Opens as designed (a picture in the file's own fonts and colors).
  • o switches to the terminal's font: markdown text and tables. The page stays the same.
  • i switches the designed page between real colors and terminal-painted.
  • The footer shows both keys.

Older and Apple formats (.doc, .ppt, .key, .pages, .numbers) get a message saying what to save them as.

Tests

cargo test: 591 pass. New tests cover Word headings, emphasis, fields, list numbering, tables, pagination shared by both looks, and rendering, plus Excel style and sheet parsing and grid drawing. Also checked by eye on a real .docx and on styled .xlsx and .csv files.

🤖 Generated with Claude Code


Summary by cubic

Leaf now opens Word, PowerPoint, and Excel files natively — it reads the zip/XML directly, so no LibreOffice, Keynote, Pages, or Numbers is needed and files open in milliseconds on macOS and Linux. Older and Apple formats (.doc, .ppt, .key, .pages, .numbers) show a message suggesting what to save them as.

Rendering

  • Decks draw each slide from its master, layout, and theme: shapes, pictures, tables, charts, and SmartArt, with speaker notes beneath; in the terminal look, side-by-side cards read one at a time and the largest short line becomes the title.
  • Word documents lay out styles, lists, tables, pictures, and fields on the document's own page size and margins; list numbering restarts where Word says and otherwise continues across shared definitions, as Word does.
  • Spreadsheets draw a real grid with column letters and row numbers; .xlsx/.xlsm workbooks keep cell fonts, fills, borders, alignment, widths, and heights while other formats get a plain grid, and a narrow sheet takes its share of the column.

Views

  • Files open as designed, in their own fonts and colors; pages fill the reading column, and +/- zooms.
  • o switches to the terminal's font (markdown and tables) keeping the same page, and i switches the designed page between real colors and terminal-painted colors.
  • a in the designed look switches to the text and reads it aloud; o stops reading.
  • Damaged or hostile files are capped and bounded instead of crashing.

Written for commit a05cd06. Summary will update on new commits.

View guided diff Turn on auto-fix

… and a terminal look

leaf now opens .docx, .pptx and .xlsx/.xls/.ods/.csv/.tsv itself on macOS
and Linux, with no LibreOffice, Keynote, Pages or Numbers.

- Decks: each slide drawn from its XML with master, layout and theme
  (shapes, pictures, fonts, tables, charts, SmartArt), speaker notes below.
- Word: styles, numbering, tables, pictures and fields laid out on the
  document's own page size and margins, drawn page by page.
- Spreadsheets: a grid with column letters and row numbers; Excel cell
  fonts, fills, borders, alignment, column widths and row heights.
- `o` switches any office file between the designed look and the
  terminal's font (markdown text and tables) on the same page; `i` paints
  the designed page in terminal colors. The footer shows both keys.
- Older and Apple formats (.doc, .ppt, .key, .pages, .numbers) say what to
  save them as. Docs, CHANGELOG and completions list only what's read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 22 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread skills/leaf/SKILL.md Resolved
Comment thread src/drawing.rs Resolved
Comment thread src/word.rs Resolved
Comment thread src/chart.rs Resolved
Comment thread src/chart.rs Resolved
Comment thread src/grid.rs Resolved
Comment thread src/grid.rs Resolved
Comment thread src/sheet.rs Resolved
Comment thread src/sheet.rs Resolved
Comment thread README.md Resolved
- Office pages (slides, Word pages, sheet grids) are no longer capped at a
  figure's 28 rows, so they fill the reading column instead of shrinking
  into a corner. `+`/`-` zoom (as `>`/`<`), shown in the footer and help.
- Sheet pages drop their blank padding: a narrow sheet takes its share of
  the column, centered, and every page keeps one scale.
- Deck terminal look: shapes keep their real boxes (through groups), are
  read by widest-gap cuts so side-by-side cards read one at a time, the
  largest short line becomes the title, and backgrounds, icons, accent
  bars, duplicates, off-slide text and stray color codes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 10 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/slides.rs Resolved
Comment thread src/viewer.rs Resolved
Comment thread src/viewer.rs Resolved
Comment thread src/grid.rs Resolved
Comment thread src/grid.rs Resolved
DeepanshuMishraa and others added 2 commits November 19, 2026 12:39
… and read-aloud

- Hostile or damaged files: zip parts are read up to a 512 MB cap instead
  of trusting their claimed size; chart point indexes are bounded; xlsx
  colors and `<col min="0">` no longer panic.
- Word: lists restart where a `startOverride` says, and otherwise continue
  across lists sharing a definition, as Word does; table cells stay on one
  row when they hold line breaks or pictures.
- Text: a word set in two styles no longer breaks at the style change;
  underlined or struck spaces keep their line.
- Slides: deeper auto-numbers restart under a new parent item; donuts have
  their hole; tables in scaled groups scale; boolean flags accept "true".
- Sheets: hidden rows are hidden; numbers keep 15 significant digits;
  times keep seconds and round into the next day; page labels use the
  sheet's own row numbers and column letters on both sides; NaN/Inf text
  isn't a number; spilled text keeps the fills it crosses; long cells are
  fitted by halving instead of letter by letter.
- Charts: titles taken from a cell show; table values keep full precision.
- Pictures: sizes follow EXIF orientation, so rotated photos keep their shape.
- Reader: `a` in the designed look switches to the text and reads it; `o`
  stops reading aloud, as a reload does.
- Docs: the skill triggers on office files; README and CHANGELOG say which
  spreadsheets keep their styles, and list .xla/.xlam.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and zoom hints

- Word: each section keeps its own page size and margins (a landscape
  section stays landscape); a page break after a paragraph's last words
  moves what follows to the next page.
- Sheets: text spills past a page's last column only when it's the
  sheet's last, so it can't cover data on the next page; the column-letter
  band runs over the spill too.
- Slides: reading order always cuts with blocks on both sides, so shapes
  without positions can't recurse forever.
- Reader: `- +` are listed with the width keys for every document, and the
  footer's zoom hint hides while a drawing is picked, as they resize it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 14 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/slides.rs">

<violation number="1" location="src/slides.rs:973">
P3: The new scaled-group table path and the `"true"` acceptance in `flag` have no regression test. Add one that renders a table inside a scaled `grpSp` and one with `firstRow="true"`.</violation>
</file>

<file name="src/office.rs">

<violation number="1" location="src/office.rs:91">
P3: The doc comment says the size is read without decoding, but the fallback calls `prmedia::decode`, which fully rasterizes SVGs. Say that the header is used when the format allows and the picture is decoded otherwise.</violation>
</file>

<file name="CHANGELOG.md">

<violation number="1" location="CHANGELOG.md:5">
P3: This release note omits `.xlsm`, `.xlsb`, `.xla`, and `.xlam` from its supported spreadsheet list, then advertises `.xlsm` later. Include the full list or label the entries as examples.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/slides.rs
if (sx - 1.0).abs() > 1e-3 || (sy - 1.0).abs() > 1e-3 {
let _ = write!(
canvas.body,
r#"<g transform="translate({:.2} {:.2}) scale({sx:.4} {sy:.4})">"#,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new scaled-group table path and the "true" acceptance in flag have no regression test. Add one that renders a table inside a scaled grpSp and one with firstRow="true".

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/slides.rs, line 973:

<comment>The new scaled-group table path and the `"true"` acceptance in `flag` have no regression test. Add one that renders a table inside a scaled `grpSp` and one with `firstRow="true"`.</comment>

<file context>
@@ -965,7 +964,26 @@ impl<'a, 'i> Ctx<'a, 'i> {
+            if (sx - 1.0).abs() > 1e-3 || (sy - 1.0).abs() > 1e-3 {
+                let _ = write!(
+                    canvas.body,
+                    r#"<g transform="translate({:.2} {:.2}) scale({sx:.4} {sy:.4})">"#,
+                    rect.x, rect.y
+                );
</file context>

Comment thread src/office.rs
Comment on lines +91 to +92
/// A picture's size in pixels as `picture_pixels` gives it, turned upright
/// by its EXIF orientation, read from its header without decoding it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The doc comment says the size is read without decoding, but the fallback calls prmedia::decode, which fully rasterizes SVGs. Say that the header is used when the format allows and the picture is decoded otherwise.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/office.rs, line 91:

<comment>The doc comment says the size is read without decoding, but the fallback calls `prmedia::decode`, which fully rasterizes SVGs. Say that the header is used when the format allows and the picture is decoded otherwise.</comment>

<file context>
@@ -88,13 +88,27 @@ pub fn open(path: &Path) -> Result<Doc, String> {
 }
 
-/// A picture's size in pixels, read without decoding all of it.
+/// A picture's size in pixels as `picture_pixels` gives it, turned upright
+/// by its EXIF orientation, read from its header without decoding it.
 pub fn picture_size(bytes: &[u8]) -> Option<(u32, u32)> {
</file context>
Suggested change
/// A picture's size in pixels as `picture_pixels` gives it, turned upright
/// by its EXIF orientation, read from its header without decoding it.
/// A picture's size in pixels as `picture_pixels` gives it, turned upright
/// by its EXIF orientation. Read from the header where the format allows, else decoded.

Comment thread CHANGELOG.md

## Unreleased

- Open Word documents (`.docx`), slide decks (`.pptx`) and spreadsheets (`.xlsx`, `.xls`, `.ods`, `.csv`, `.tsv`). leaf reads them itself on macOS and Linux, with no LibreOffice, Keynote or Numbers. Decks and documents show as designed, in their own fonts, colors and layout, and spreadsheets as a grid; `+`/`-` zoom, `o` switches to the terminal's font, and `i` paints the designed page in the terminal's colors. Decks show one slide per page with speaker notes, Word documents keep their pages, and `.xlsx`/`.xlsm` workbooks keep their cell styles, column widths and row heights.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This release note omits .xlsm, .xlsb, .xla, and .xlam from its supported spreadsheet list, then advertises .xlsm later. Include the full list or label the entries as examples.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At CHANGELOG.md, line 5:

<comment>This release note omits `.xlsm`, `.xlsb`, `.xla`, and `.xlam` from its supported spreadsheet list, then advertises `.xlsm` later. Include the full list or label the entries as examples.</comment>

<file context>
@@ -2,7 +2,7 @@
 ## Unreleased
 
-- Open Word documents (`.docx`), slide decks (`.pptx`) and spreadsheets (`.xlsx`, `.xls`, `.ods`, `.csv`, `.tsv`). leaf reads them itself on macOS and Linux, with no LibreOffice, Keynote or Numbers. Each shows as designed, in its own fonts, colors and layout; `o` switches to the terminal's font, and `i` paints the designed page in the terminal's colors. Decks show one slide per page with speaker notes, Word documents keep their pages, and spreadsheets keep their cell styles and column widths.
+- Open Word documents (`.docx`), slide decks (`.pptx`) and spreadsheets (`.xlsx`, `.xls`, `.ods`, `.csv`, `.tsv`). leaf reads them itself on macOS and Linux, with no LibreOffice, Keynote or Numbers. Decks and documents show as designed, in their own fonts, colors and layout, and spreadsheets as a grid; `+`/`-` zoom, `o` switches to the terminal's font, and `i` paints the designed page in the terminal's colors. Decks show one slide per page with speaker notes, Word documents keep their pages, and `.xlsx`/`.xlsm` workbooks keep their cell styles, column widths and row heights.
 - Configure the document reader's maximum width in `$XDG_CONFIG_HOME/leaf/config.toml` (default `~/.config/leaf/config.toml`). Omitted settings keep the 76-column layout.
 - Keep the reading position within PDF and EPUB pages when resizing in scroll mode.
</file context>
Suggested change
- Open Word documents (`.docx`), slide decks (`.pptx`) and spreadsheets (`.xlsx`, `.xls`, `.ods`, `.csv`, `.tsv`). leaf reads them itself on macOS and Linux, with no LibreOffice, Keynote or Numbers. Decks and documents show as designed, in their own fonts, colors and layout, and spreadsheets as a grid; `+`/`-` zoom, `o` switches to the terminal's font, and `i` paints the designed page in the terminal's colors. Decks show one slide per page with speaker notes, Word documents keep their pages, and `.xlsx`/`.xlsm` workbooks keep their cell styles, column widths and row heights.
- Open Word documents (`.docx`), slide decks (`.pptx`) and spreadsheets (`.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xla`, `.xlam`, `.ods`, `.csv`, `.tsv`). leaf reads them itself on macOS and Linux, with no LibreOffice, Keynote or Numbers. Decks and documents show as designed, in their own fonts, colors and layout, and spreadsheets as a grid; `+`/`-` zoom, `o` switches to the terminal's font, and `i` paints the designed page in the terminal's colors. Decks show one slide per page with speaker notes, Word documents keep their pages, and `.xlsx`/`.xlsm` workbooks keep their cell styles, column widths and row heights.

@DeepanshuMishraa
DeepanshuMishraa merged commit 8aa7ed3 into main Nov 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant