Semantic line break formatter for Org, LaTeX, Markdown, and plaintext
Project description
Table of Contents
About
A fast, format-aware semantic line break formatter. Reformats prose so each sentence occupies its own line, producing minimal and meaningful git diffs when collaborating on documents.
Why?
When multiple authors collaborate on a paper using Git, traditional line wrapping at a fixed column width causes problems. A single word change can trigger a diff that spans an entire paragraph. By breaking at sentence boundaries instead, each edit affects only the sentence that changed.
This convention, often called semantic line breaks, enjoys longstanding support from technical writers.
Existing tools fall short: latexindent.pl only handles LaTeX, SemBr requires Python and neural networks, and most lack multi-format awareness.
snapper solves this as a standalone Rust binary with no runtime dependencies, handling Org-mode, LaTeX, Markdown, and plaintext.
Design
snapper runs a three-stage pipeline:
- Parse: Classify input into prose regions and structure regions
- Split: Detect sentence boundaries in prose regions
- Emit: Output each sentence on its own line
Structure regions (code blocks, math environments, tables, front matter, drawers, comments) pass through unchanged. Sentence detection relies on Unicode UAX #29 segmentation with abbreviation-aware post-processing that avoids false breaks at titles (Dr., Prof.), references (Fig., Eq.), and Latin terms (e.g., i.e., et al.).
Installation
Pre-built binary (fastest):
cargo binstall snapper-fmt
Shell one-liner (Linux/macOS):
curl -LsSf https://github.com/TurtleTech-ehf/snapper/releases/latest/download/snapper-fmt-installer.sh | sh
Homebrew:
brew install TurtleTech-ehf/tap/snapper-fmt
pip:
pip install snapper-fmt
Compile from source:
cargo install snapper-fmt
Nix:
nix build github:TurtleTech-ehf/snapper
The crate is snapper-fmt on all registries; the binary it installs is snapper.
Usage
Format a file (output to stdout):
snapper paper.org
Format in place:
snapper --in-place paper.org
Pipe through stdin (for editor integration):
cat draft.org | snapper --format org
Check formatting without modifying (for CI):
snapper --check paper.org paper.tex notes.md
Limit line width (wrap long sentences at word boundaries):
snapper --max-width 80 paper.org
Preview changes as a unified diff before committing:
snapper --diff paper.org
Compare two versions at the sentence level (whitespace reflow produces zero diff):
snapper sdiff paper_v1.org paper_v2.org
Watch files and auto-reformat on save:
snapper watch '*.org' 'sections/*.tex'
Initialize a project (generates config, pre-commit, gitattributes):
snapper init
MCP server (AI assistants)
Expose snapper's tools to Claude Desktop, Claude Code, and other MCP clients:
npx @turtletech/snapper-mcp
Or directly:
snapper mcp
Tools: format_text, detect_format, check_formatting, split_sentences.
See MCP Integration for configuration.
Supported formats
| Format | Extensions | Structure preserved |
|---|---|---|
| Org-mode | .org |
Blocks, drawers, tables, keywords |
| LaTeX | .tex, .latex |
Preamble, math, environments, comments |
| Markdown | .md, .markdown |
Code blocks, front matter, HTML |
| Plaintext | everything else | (none; all text treated as prose) |
Pre-commit hook
- repo: https://github.com/TurtleTech-ehf/snapper
rev: v0.7.0
hooks:
- id: snapper
Emacs (Apheleia)
(with-eval-after-load 'apheleia
(push '(snapper . ("snapper" "--format" "org")) apheleia-formatters)
(push '(org-mode . snapper) apheleia-mode-alist))
VS Code
Install TurtleTech.snapper from the VS Code Marketplace. The extension uses the built-in LSP server for format-on-save, range formatting, diagnostics, and code actions.
Neovim
With lazy.nvim (rocks support):
{
"TurtleTech-ehf/snapper",
ft = { "org", "tex", "markdown", "rst" },
config = function()
vim.opt.runtimepath:append(
vim.fn.stdpath("data") .. "/lazy/snapper/editors/nvim"
)
require("snapper").setup()
end,
}
Or with rocks.nvim:
:Rocks install snapper.nvim
Vim
Plug 'TurtleTech-ehf/snapper', { 'rtp': 'editors/vim' }
This provides formatprg support for automatic formatting with the gq operator.
Obsidian
Install the snapper plugin from Community Plugins (search "Snapper"). Uses WebAssembly -- no binary installation required.
Microsoft Word
Install the snapper add-in from AppSource (Insert > Get Add-ins > search "Snapper"). Uses WebAssembly -- no binary installation required.
Git smudge/clean filter
Auto-format on commit, transparent to collaborators:
git config filter.snapper.clean "snapper --format org"
git config filter.snapper.smudge cat
Then add to .gitattributes:
*.org filter=snapper
Vale integration
snapper ships a vale style package for editor hints.
Add to your .vale.ini:
StylesPath = /path/to/snapper/vale
[*.org]
BasedOnStyles = snapper
For precise CI checks, use snapper --check directly.
Project config
Drop a .snapperrc.toml in your project root:
extra_abbreviations = ["GROMACS", "LAMMPS", "DFT"]
ignore = ["*.bib", "*.cls"]
format = "org"
max_width = 0
snapper walks up from the current directory to find it.
Documentation
Build the docs site with:
pixi run docbld
Development
Key dependencies
- Clap 4 (derive): CLI argument parsing
- unicode-segmentation: UAX #29 sentence boundaries
- regex: Abbreviation and format pattern matching
- textwrap: Optional line width limiting
- thiserror: Typed error handling
Conventions
We use cocogitto via cog to handle commit conventions.
Readme
Construct the readme via:
./scripts/org_to_md.sh readme_src.org README.md
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snapper_fmt-0.7.2.tar.gz.
File metadata
- Download URL: snapper_fmt-0.7.2.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dd28fa846936555cc418745895683091da731837930ea2c07e491e5feeb6085
|
|
| MD5 |
dfd535f098ac6344d5de5163c62f654b
|
|
| BLAKE2b-256 |
de7282ac137a7580e6e5b37678048024f4afa2692ebb0a56b4fa166731d51149
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2.tar.gz:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2.tar.gz -
Subject digest:
7dd28fa846936555cc418745895683091da731837930ea2c07e491e5feeb6085 - Sigstore transparency entry: 1258658237
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type:
File details
Details for the file snapper_fmt-0.7.2-py3-none-win_amd64.whl.
File metadata
- Download URL: snapper_fmt-0.7.2-py3-none-win_amd64.whl
- Upload date:
- Size: 7.2 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac8f23b6051b51d99053f675e1623ddd4f903ecf76946fe5da52d3ef6dcd161d
|
|
| MD5 |
b3e844c6f34a6cc5ca0113e657a28e5a
|
|
| BLAKE2b-256 |
37045324b557f52d4c534d91492690c71866d187d985be24d0b56c27e5620d4a
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2-py3-none-win_amd64.whl:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2-py3-none-win_amd64.whl -
Subject digest:
ac8f23b6051b51d99053f675e1623ddd4f903ecf76946fe5da52d3ef6dcd161d - Sigstore transparency entry: 1258659044
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type:
File details
Details for the file snapper_fmt-0.7.2-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: snapper_fmt-0.7.2-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19d0d9461dc0769189deb5c3abd90a99dca6a29bf06da49851d79257942b93f8
|
|
| MD5 |
fa67e58937a4dd285c15d05d5037d7df
|
|
| BLAKE2b-256 |
dd8c6de808e9c8854458028fa162cbcaedc287e838ca458c5811fbb0e39ab90f
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
19d0d9461dc0769189deb5c3abd90a99dca6a29bf06da49851d79257942b93f8 - Sigstore transparency entry: 1258658753
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type:
File details
Details for the file snapper_fmt-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: snapper_fmt-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 7.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87ddda531c56473fad658b41a225f5efb4b51f8c961d29ae5e9bb996d0f5b9f2
|
|
| MD5 |
bdee1ecc0c04cf087fb375f641af4543
|
|
| BLAKE2b-256 |
30777318efdb5b7f247f3907b6a41323ed64af1751634b0f06ad934a6a0f7775
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
87ddda531c56473fad658b41a225f5efb4b51f8c961d29ae5e9bb996d0f5b9f2 - Sigstore transparency entry: 1258659528
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type:
File details
Details for the file snapper_fmt-0.7.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: snapper_fmt-0.7.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e78f08925e4685785142e36dc1bb5fb43d53fe2f13e33ce61063e17233662d81
|
|
| MD5 |
d41317d709a371c48a5f8720197325e9
|
|
| BLAKE2b-256 |
767d481b2cb45f6ee7948d351a9987edeab6a338c469dab36e2694d08ef7af20
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
e78f08925e4685785142e36dc1bb5fb43d53fe2f13e33ce61063e17233662d81 - Sigstore transparency entry: 1258659388
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type:
File details
Details for the file snapper_fmt-0.7.2-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: snapper_fmt-0.7.2-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.7 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cf41d1db00983706fce054740c34c8e15e081f8ed71c41832be94ac3ec9f339
|
|
| MD5 |
b37f1ad2e9e6098afcfc8f0da5bf98b4
|
|
| BLAKE2b-256 |
7ae9a6ecb0cdd2a0d1fb5a8d24a01b114a6b4e66ccc67faaad3f4cfb676d1f8b
|
Provenance
The following attestation bundles were made for snapper_fmt-0.7.2-py3-none-macosx_10_12_x86_64.whl:
Publisher:
pypi.yml on TurtleTech-ehf/snapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapper_fmt-0.7.2-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
1cf41d1db00983706fce054740c34c8e15e081f8ed71c41832be94ac3ec9f339 - Sigstore transparency entry: 1258658533
- Sigstore integration time:
-
Permalink:
TurtleTech-ehf/snapper@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/TurtleTech-ehf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@15467dbbeb77abb5129451a7c9f0135c8f74d9bb -
Trigger Event:
push
-
Statement type: