Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

htmst

PyPI - Python Versions PyPI - Version GitHub

htmst is a python library for parsing html into AST with positions.

Installation

uv add htmst

or

pip install htmst

Usage

from htmst import HtmlAst

html = """<span foo="bar">hi</span>"""
ast = HtmlAst(html)

print(ast.root.children[0].tag) # span

print(ast.root.children[0].start.row) # 0
print(ast.root.children[0].start.col) # 0

print(ast.root.children[0].end.row) # 0
print(ast.root.children[0].end.col) # 25

print(ast.root.children[0].attrs[0].name) # foo
print(ast.root.children[0].attrs[0].value) # bar

print(ast.root.children[0].attrs[0].start.row) # 0
print(ast.root.children[0].attrs[0].start.col) # 6

print(ast.root.children[0].attrs[0].end.row) # 0
print(ast.root.children[0].attrs[0].end.col) # 15

Nodes

  • DoubleTagNode: represents double tags
  • SingleTagNode: represents single tags
  • AttrNode: represents attributes
  • TextNode: represents texts
  • CommentNode: represents comments
  • DoctypeNode: represents doctypes

Each node has a start and end position.

Contributing

Contributions are welcome! Please read the contributing guidelines for more information.

License

This project is licensed under the MIT License.

Metadata

Release files for htmst 1.0a9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for htmst 1.0a9
File Size Uploaded
htmst-1.0a9.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for htmst 1.0a9
File Interpreter ABI Platform
htmst-1.0a9-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / htmst-1.0a9.tar.gz

Download URL htmst-1.0a9.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a3c86f722b0e54969298e5b575897c616878075d0e22a1adf519a0769aedb1c2
BLAKE2b-256 checksum
How to use checksums
d7d9bb3759c655792b62e834cfed207f301cf1f0886ac0f55099ae72f6e7588c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / htmst-1.0a9-py3-none-any.whl

Download URL htmst-1.0a9-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f2e58c0b1379ede495de1f3e3dc3c197a68af35b3f7dd9d3047ab46f181897d
BLAKE2b-256 checksum
How to use checksums
10a7170fff1df013443f4376139943f88539d106eaa05716fbbb5b9dc6c0a1cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page