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.1.0.tar.gz (341.4 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.1.0-py3-none-any.whl (79.6 kB view details)

Uploaded Python 3

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

Hashes for flexdoc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 37c6fc533fa8075f9a783d0922937d239f66a5bf763ad6b32a24587f0a781c73
MD5 5b625a851e5a2d6f14b60063f6003bf5
BLAKE2b-256 0682f58d8d0b6250c28e11a226cc0a6220d729bf060f2a4ec4bcef8dde4d722a

See more details on using hashes here.

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

Hashes for flexdoc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4fae55a2e399b4ad8b85e4c3d8b959edad4cb424e5f198268736e171e34f275
MD5 aa272d7b97c564ab318d86d7dbe118bb
BLAKE2b-256 2588a41fbfa44177d69f8e037abdd7236a1e4477d06c249212d6c805fed6429f

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