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
TextNode
: represents textsAttrNode
: represents attributesDoubleNode
: represents double tagsSingleNode
: represents single tagsCommentNode
: 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.0a1.tar.gz
(6.7 kB
view details)
Built Distribution
htmst-1.0a1-py3-none-any.whl
(5.7 kB
view details)
File details
Details for the file htmst-1.0a1.tar.gz
.
File metadata
- Download URL: htmst-1.0a1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4b8c4b5575e6b234d058d5f3420b9822258965b72bcd07adf270cde0a2651c |
|
MD5 | f2fefae2e0c6d8ef612a0404bd612483 |
|
BLAKE2b-256 | 1a65b86a505264baab111c9c9243e90671d43e7a01196e65a72a6b63bd3cef61 |
File details
Details for the file htmst-1.0a1-py3-none-any.whl
.
File metadata
- Download URL: htmst-1.0a1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bdbae05ac0cbbcd8856e52b895c7b0a1f992ab2b19dc360d31f716727649d43 |
|
MD5 | 523a49004de048241cbb94d52cb3c5b3 |
|
BLAKE2b-256 | b38960ffb33d75c12bbec72b6a81acb530009924e573c9f032771fa069ea319a |