Python utilities for parsing, traversing, editing, and serializing TipTap JSON content.
Project description
tiptap_python_utils
Python utilities for TipTap JSON content.
tiptap_python_utils parses TipTap documents into typed Python nodes, preserves
unknown/custom nodes for lossless round trips, and provides small helpers for
traversal, immutable edits, visible text extraction, task queries, and shared
node synchronization.
The package has no runtime dependencies.
Install
pip install tiptap_python_utils
Quick Start
from tiptap_python_utils import Content, Paragraph, Text, kind
raw = {
"type": "doc",
"content": [
{
"type": "paragraph",
"attrs": {"id": "p1"},
"content": [{"type": "text", "text": "Old"}],
}
],
}
updated = Content.require(raw).where_id("p1").text("New").dump()
Typed Nodes
Build typed nodes directly and serialize them back to TipTap-compatible JSON:
node = Paragraph(id="p1", content=(Text(value="Hello"),))
doc = Content.wrap(node.raw())
Unknown/custom node types are preserved as Unknown nodes and round-trip without
dropping extra fields.
Selection And Editing
Select nodes by id or TipTap kind:
updated = Content.require(raw).of(kind.PARAGRAPH).attr("color", "blue").dump()
Selection methods return updated immutable content:
updated = (
Content.require(raw)
.where_id("p1")
.text("Updated")
.attr("data-state", "reviewed")
.dump()
)
Text Extraction
Extract visible text or contextual slices:
from tiptap_python_utils import Content, text_slices, visible_text, word_count
content = Content.require(raw)
plain_text = visible_text(content)
count = word_count(content)
slices = text_slices(content, context=True)
Tasks
from tiptap_python_utils import Content, has_open_tasks, open_tasks
content = Content.require(raw)
pending = has_open_tasks(content)
items = open_tasks(content)
Public API
Common imports are available from the package root:
from tiptap_python_utils import (
Content,
Paragraph,
TaskItem,
Text,
append_node,
has_open_tasks,
kind,
replace_node,
shared_families,
sync_shared,
text_slices,
)
Development
python -m pip install -e ".[dev]"
pytest -q
Build and check a release artifact:
python -m build
python -m twine check dist/*
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
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 tiptap_python_utils-0.1.0.tar.gz.
File metadata
- Download URL: tiptap_python_utils-0.1.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a138c069ec9c0f121d4b447339b57f1baff292fe9c32d5fc7e59fb893f26b4ef
|
|
| MD5 |
c8e1f57ad4ad033b63e2903b7aebe194
|
|
| BLAKE2b-256 |
ba00feb4b170cd939369427a70e63633eaf0fd809e3e440c7a656eb2967e232c
|
Provenance
The following attestation bundles were made for tiptap_python_utils-0.1.0.tar.gz:
Publisher:
publish.yml on tugkanpilka/tiptap-python-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tiptap_python_utils-0.1.0.tar.gz -
Subject digest:
a138c069ec9c0f121d4b447339b57f1baff292fe9c32d5fc7e59fb893f26b4ef - Sigstore transparency entry: 1654483145
- Sigstore integration time:
-
Permalink:
tugkanpilka/tiptap-python-utils@5213cbd98588b0fc86479f2a519dea3c514dd283 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tugkanpilka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5213cbd98588b0fc86479f2a519dea3c514dd283 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tiptap_python_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tiptap_python_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c2169046abef925c90509ece81bae6d0c8f0eb544e10cd6c208499144ebd17b
|
|
| MD5 |
f7566efa33390ef3541acce38402745b
|
|
| BLAKE2b-256 |
84c1bb3e7e5370a9180737e0e19dc4e2534721b27958b6ba8e49340e80e73613
|
Provenance
The following attestation bundles were made for tiptap_python_utils-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on tugkanpilka/tiptap-python-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tiptap_python_utils-0.1.0-py3-none-any.whl -
Subject digest:
5c2169046abef925c90509ece81bae6d0c8f0eb544e10cd6c208499144ebd17b - Sigstore transparency entry: 1654483429
- Sigstore integration time:
-
Permalink:
tugkanpilka/tiptap-python-utils@5213cbd98588b0fc86479f2a519dea3c514dd283 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tugkanpilka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5213cbd98588b0fc86479f2a519dea3c514dd283 -
Trigger Event:
workflow_dispatch
-
Statement type: