Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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. 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.

- 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.
- `<` and `>` narrow or widen the reading column, and `=` fits it to the screen, so wide diagrams can be read without quitting.
Expand Down
153 changes: 153 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = "src/main.rs"

[dependencies]
base64 = "0.22"
calamine = "0.38"
crossterm = "0.29"
dither-ratatui = "0.1.0"
dom_smoothie = "0.18"
Expand All @@ -28,12 +29,13 @@ pulldown-cmark = { version = "0.13", default-features = false }
ratatui = "0.30"
ratatui-image = { version = "12.0.0-rc.2", default-features = false, features = ["crossterm"] }
regex = "1"
resvg = { version = "0.48", default-features = false, features = ["text", "system-fonts", "memmap-fonts"] }
resvg = { version = "0.48", default-features = false, features = ["text", "system-fonts", "memmap-fonts", "raster-images"] }
rodio = { version = "0.23.0", default-features = false, features = ["playback"] }
rusqlite = { version = "0.40", features = ["bundled"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0.154", features = ["preserve_order"] }
sha2 = "0.11.1"
skrifa = { version = "0.44", default-features = false, features = ["std"] }
symphonia = { version = "0.6.1", default-features = false, features = ["mp3"] }
thiserror = "2"
toml = { version = "1.2.1", default-features = false, features = ["std", "parse", "serde"] }
Expand All @@ -43,6 +45,7 @@ unicode-width = "0.2"
ureq = "3"
url = "2"
wasmtime = { version = "50.0.0", default-features = false, features = ["cranelift", "parallel-compilation", "runtime", "std"] }
zip = { version = "9.7", default-features = false, features = ["deflate"] }

# Load fontconfig at run time instead of linking it, so building on Linux
# doesn't need its development package (libfontconfig1-dev). mupdf's
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ If `leaf` isn't found after installing, add `~/.cargo/bin` to your PATH (fish: `
ln -s (pwd)/completions/leaf.fish ~/.config/fish/completions/ # fish: tab-completes .pdf and .md files
leaf open paper.pdf
leaf open README.md
leaf open talk.pptx
leaf open budget.xlsx
leaf open https://example.com/post
```

Expand Down Expand Up @@ -77,7 +79,17 @@ PDFs are converted to markdown (headings from font size, paragraphs rejoined, ru

Markdown files (`.md`, `.markdown`) show as written, with GitHub's extensions: tables, task lists, strikethrough, footnotes and alerts (`> [!NOTE]`), plus definition lists and math (kept as source). Front matter is hidden, HTML blocks such as a README's centered logo are read as markdown, and images next to the file show inline (PNG, JPEG, GIF, WebP).

Local Markdown, PDF, EPUB, and picture files reload in place after changes settle. Reloading pauses while you select text or use a dialog. Failed reloads wait five seconds before retrying, unless the file changes again. PDF and EPUB replacements load in the background while you keep reading the current document.
Office files open too, for reading. leaf reads them itself, the same on macOS and Linux, with nothing else installed:

- **Slide decks** (`.pptx`, `.pptm`, `.ppsx`, `.ppsm`, `.potx`, `.potm`) show one slide per page, with speaker notes beneath. `←/→` move between slides.
- **Word documents** (`.docx`, `.docm`, `.dotx`, `.dotm`) show page by page, on the document's own page size and margins, with its lists, tables and pictures.
- **Spreadsheets** (`.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xla`, `.xlam`, `.ods`) and **CSV/TSV** files show each sheet in pages of 60 rows and 8 columns. The header row tops every page, and the first column starts every page of a wide sheet. Semicolon-separated CSV is detected.

Decks and Word documents open as designed, drawn as a picture in their own fonts, colors and layout. Spreadsheets open as a grid: `.xlsx` and `.xlsm` workbooks keep their cell fonts, fills, borders, column widths and row heights; other spreadsheets and CSV/TSV files get a plain grid sized to their cells. `+` and `-` zoom (as `>` and `<` do), and `=` fits a page to the screen. `o` switches to the terminal's font and colors, as markdown text and tables; the page stays the same. In the designed look, `i` switches between real colors and the picture painted in the terminal's colors, as with PDFs. The footer shows these keys.

Older formats (`.doc`, `.ppt`, `.rtf`, `.odt`, `.odp`) and Apple's (`.pages`, `.key`, `.numbers`) aren't read; save them as `.docx`, `.pptx` or `.xlsx` from the app that made them.

Local Markdown, PDF, EPUB, office, and picture files reload in place after changes settle. Reloading pauses while you select text or use a dialog. Failed reloads wait five seconds before retrying, unless the file changes again. PDF and EPUB replacements load in the background while you keep reading the current document.

`mermaid` code blocks are drawn as diagrams in the terminal's colors, with [Pele](https://github.com/obsidianmd/pele) run under `bun` or `node`; without either, or for a diagram Pele can't read, the block shows as code.

Expand Down
3 changes: 2 additions & 1 deletion completions/_leaf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ _leaf() {
# HEIC, HEIF, AVIF and JPEG XL need macOS's sips.
local pictures='png|jpg|jpeg|jpe|jfif|gif|webp|bmp|ico|tif|tiff|tga|pnm|pbm|pgm|ppm|pam|qoi|hdr|exr|dds|ff|svg'
[[ $OSTYPE == darwin* ]] && pictures+='|jxl|heic|heif|avif'
_arguments "*:document:_files -g \"(#i)*.(pdf|epub|md|markdown|$pictures)\""
local office='docx|docm|dotx|dotm|pptx|pptm|ppsx|ppsm|potx|potm|xlsx|xlsm|xlsb|xls|xla|xlam|ods|csv|tsv'
_arguments "*:document:_files -g \"(#i)*.(pdf|epub|md|markdown|$office|$pictures)\""
;;
diff)
_leaf_diff
Expand Down
4 changes: 2 additions & 2 deletions completions/leaf.fish
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Completions for leaf. Install: ln -s (pwd)/completions/leaf.fish ~/.config/fish/completions/
complete -c leaf -f
complete -c leaf -n __fish_use_subcommand -a open -d 'Read a PDF, markdown file or web page'
complete -c leaf -n '__fish_seen_subcommand_from open' -a '(__fish_complete_suffix .pdf .epub .md .markdown .png .jpg .jpeg .jpe .jfif .gif .webp .bmp .ico .tif .tiff .tga .pnm .pbm .pgm .ppm .pam .qoi .hdr .exr .dds .ff .svg)'
complete -c leaf -n __fish_use_subcommand -a open -d 'Read a PDF, office file, markdown file or web page'
complete -c leaf -n '__fish_seen_subcommand_from open' -a '(__fish_complete_suffix .pdf .epub .md .markdown .docx .docm .dotx .dotm .pptx .pptm .ppsx .ppsm .potx .potm .xlsx .xlsm .xlsb .xls .xla .xlam .ods .csv .tsv .png .jpg .jpeg .jpe .jfif .gif .webp .bmp .ico .tif .tiff .tga .pnm .pbm .pgm .ppm .pam .qoi .hdr .exr .dds .ff .svg)'
# HEIC, HEIF, AVIF and JPEG XL need macOS's sips.
test (uname) = Darwin; and complete -c leaf -n '__fish_seen_subcommand_from open' -a '(__fish_complete_suffix .jxl .heic .heif .avif)'
complete -c leaf -n __fish_use_subcommand -a diff -d 'Review a diff'
Expand Down
4 changes: 2 additions & 2 deletions lua/leaf/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ function M.setup(opts)
name = "leaf_open",
title = "Leaf: Open Document…",
description = "Open leaf's home in this pane: today's reading, a heat map of the days you read,"
.. " and a search over recent documents and this folder's PDFs, EPUBs and markdown files.",
.. " and a search over recent documents and this folder's PDFs, EPUBs, markdown and office files.",
category = "Leaf",
keywords = "leaf pdf markdown epub read document article book file picker",
keywords = "leaf pdf markdown epub word powerpoint excel slides spreadsheet read document article book file picker",
args = { target = "string?" },
run = function(ctx, args)
local target = args.target or ""
Expand Down
Loading