Document model for powerful text parsing and processing in Markdown
Project description
flexdoc
flexdoc is a source-grounded, layered document model for Markdown and text.
It parses a document into a FlexDoc, lets you query its structure across independent
layers with a single collect() primitive, serializes it as a DocGraph, and anchors
spans and edits with SpanRef so they survive a reparse.
The aim is fine-grained understanding of a complex Markdown document along several independent axes at once — its Markdown syntax (blocks, inline elements, exact spans, typed attributes), its grammar and language (paragraphs, sentences, tokens), and other structures layered onto the same text — over one shared coordinate space.
flexdoc is a standalone library. chopdiff builds its diff-filtering and windowed-transform layer on top of flexdoc.
Installation
uv add flexdoc
# or: pip install flexdoc
Usage
The primary entry point is FlexDoc, importable from the package root; the full public
surfaces live in the submodules:
flexdoc.docs—FlexDoc,Paragraph,Sentence,Section,Block,BlockType, the node table,collect(),DocGraph,SpanRef, token diffs/mappings, and word-token utilities.flexdoc.html— html-in-md, html/plaintext conversion, HTML tag helpers, the content extractor, and timestamp extraction.flexdoc.util— read-time and token-count estimation.
from flexdoc import FlexDoc
doc = FlexDoc.from_text("# Title\n\nHello world. This is a second sentence.\n")
# Round-trips back to normalized Markdown.
print(doc.reassemble())
# Human-readable size stats (paragraphs, sentences, words, ...).
print(doc.size_summary())
See usage.md for the main workflows and examples/ for
worked scripts. From a repository checkout, run examples with
uv run python examples/<name>.py.
Project Docs
- Design of record: docs/flexdoc-spec.md.
- The extraction program and the model’s design history: docs/project/specs/active/.
- For how to install uv and Python, see installation.md.
- For development workflows, see development.md.
- For publishing to PyPI, see publishing.md.
- Dependency policy: SUPPLY-CHAIN-SECURITY.md.
This project was built from simple-modern-uv.
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 Distribution
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 flexdoc-0.1.0.tar.gz.
File metadata
- Download URL: flexdoc-0.1.0.tar.gz
- Upload date:
- Size: 341.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37c6fc533fa8075f9a783d0922937d239f66a5bf763ad6b32a24587f0a781c73
|
|
| MD5 |
5b625a851e5a2d6f14b60063f6003bf5
|
|
| BLAKE2b-256 |
0682f58d8d0b6250c28e11a226cc0a6220d729bf060f2a4ec4bcef8dde4d722a
|
File details
Details for the file flexdoc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flexdoc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 79.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4fae55a2e399b4ad8b85e4c3d8b959edad4cb424e5f198268736e171e34f275
|
|
| MD5 |
aa272d7b97c564ab318d86d7dbe118bb
|
|
| BLAKE2b-256 |
2588a41fbfa44177d69f8e037abdd7236a1e4477d06c249212d6c805fed6429f
|