HTML to AST with positions
Project description
htmst
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 tagsSingleTagNode: represents single tagsAttrNode: represents attributesTextNode: represents textsCommentNode: represents commentsDoctypeNode: 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.
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
htmst-1.0a9.tar.gz
(7.1 kB
view details)
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
htmst-1.0a9-py3-none-any.whl
(5.9 kB
view details)
File details
Details for the file htmst-1.0a9.tar.gz.
File metadata
- Download URL: htmst-1.0a9.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3c86f722b0e54969298e5b575897c616878075d0e22a1adf519a0769aedb1c2
|
|
| MD5 |
a802d520f6d17a6f69c5132c9e2abf75
|
|
| BLAKE2b-256 |
d7d9bb3759c655792b62e834cfed207f301cf1f0886ac0f55099ae72f6e7588c
|
File details
Details for the file htmst-1.0a9-py3-none-any.whl.
File metadata
- Download URL: htmst-1.0a9-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f2e58c0b1379ede495de1f3e3dc3c197a68af35b3f7dd9d3047ab46f181897d
|
|
| MD5 |
ec9d2cefb8bb73e5a645cbd6e2323f34
|
|
| BLAKE2b-256 |
10a7170fff1df013443f4376139943f88539d106eaa05716fbbb5b9dc6c0a1cd
|