Skip to main content

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.docsFlexDoc, 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


This project was built from simple-modern-uv.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flexdoc-0.2.0.tar.gz (370.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flexdoc-0.2.0-py3-none-any.whl (86.4 kB view details)

Uploaded Python 3

File details

Details for the file flexdoc-0.2.0.tar.gz.

File metadata

  • Download URL: flexdoc-0.2.0.tar.gz
  • Upload date:
  • Size: 370.8 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

Hashes for flexdoc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 983266ca6976aeba6ced9eee4a6a87fc893284b13934fc28b1e00f91717eaa0d
MD5 46cbdf9e073721eba97d339a399c4867
BLAKE2b-256 56b8497125d79205f398157c19ab072f9ac807c0ca534ba1110b8bc6ecd3db9a

See more details on using hashes here.

File details

Details for the file flexdoc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: flexdoc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 86.4 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

Hashes for flexdoc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed6d0aa79ee9460004ea11323e0363c507a038b3e4d685812bfffa85c782c04
MD5 b70692d62bffdde8c39e4fa77fcd63bf
BLAKE2b-256 5b17dbed302eca5dda3209b9b612388e200d02a7209711b9f284139cedfc1f60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page