Name | htmst JSON |
Version |
1.0a9
JSON |
| download |
home_page | None |
Summary | HTML to AST with positions |
upload_time | 2024-12-29 16:59:12 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT |
keywords |
html
parser
ast
position
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# htmst
![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/htmst)
[![PyPI - Version](https://img.shields.io/pypi/v/htmst)](https://pypi.org/project/htmst)
![GitHub](https://img.shields.io/github/license/picomet/htmst)
htmst is a python library for parsing html into AST with positions.
## Installation
```bash
uv add htmst
```
or
```bash
pip install htmst
```
## Usage
```python
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](CONTRIBUTING.md) for more information.
## License
This project is licensed under the [MIT License](LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "htmst",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "html, parser, ast, position",
"author": null,
"author_email": "Al Mahdi <picometproject@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d7/d9/bb3759c655792b62e834cfed207f301cf1f0886ac0f55099ae72f6e7588c/htmst-1.0a9.tar.gz",
"platform": null,
"description": "# htmst\n\n![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/htmst)\n[![PyPI - Version](https://img.shields.io/pypi/v/htmst)](https://pypi.org/project/htmst)\n![GitHub](https://img.shields.io/github/license/picomet/htmst)\n\nhtmst is a python library for parsing html into AST with positions.\n\n## Installation\n\n```bash\nuv add htmst\n```\n\nor\n\n```bash\npip install htmst\n```\n\n## Usage\n\n```python\nfrom htmst import HtmlAst\n\nhtml = \"\"\"<span foo=\"bar\">hi</span>\"\"\"\nast = HtmlAst(html)\n\nprint(ast.root.children[0].tag) # span\n\nprint(ast.root.children[0].start.row) # 0\nprint(ast.root.children[0].start.col) # 0\n\nprint(ast.root.children[0].end.row) # 0\nprint(ast.root.children[0].end.col) # 25\n\nprint(ast.root.children[0].attrs[0].name) # foo\nprint(ast.root.children[0].attrs[0].value) # bar\n\nprint(ast.root.children[0].attrs[0].start.row) # 0\nprint(ast.root.children[0].attrs[0].start.col) # 6\n\nprint(ast.root.children[0].attrs[0].end.row) # 0\nprint(ast.root.children[0].attrs[0].end.col) # 15\n```\n\n### Nodes\n\n- `DoubleTagNode`: represents double tags\n- `SingleTagNode`: represents single tags\n- `AttrNode`: represents attributes\n- `TextNode`: represents texts\n- `CommentNode`: represents comments\n- `DoctypeNode`: represents doctypes\n\nEach node has a `start` and `end` position.\n\n## Contributing\n\nContributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) for more information.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "HTML to AST with positions",
"version": "1.0a9",
"project_urls": {
"Funding": "https://buymeacoffee.com/almahdi404",
"Repository": "https://github.com/picomet/htmst"
},
"split_keywords": [
"html",
" parser",
" ast",
" position"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "10a7170fff1df013443f4376139943f88539d106eaa05716fbbb5b9dc6c0a1cd",
"md5": "ec9d2cefb8bb73e5a645cbd6e2323f34",
"sha256": "6f2e58c0b1379ede495de1f3e3dc3c197a68af35b3f7dd9d3047ab46f181897d"
},
"downloads": -1,
"filename": "htmst-1.0a9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ec9d2cefb8bb73e5a645cbd6e2323f34",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 5932,
"upload_time": "2024-12-29T16:59:10",
"upload_time_iso_8601": "2024-12-29T16:59:10.608179Z",
"url": "https://files.pythonhosted.org/packages/10/a7/170fff1df013443f4376139943f88539d106eaa05716fbbb5b9dc6c0a1cd/htmst-1.0a9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d7d9bb3759c655792b62e834cfed207f301cf1f0886ac0f55099ae72f6e7588c",
"md5": "a802d520f6d17a6f69c5132c9e2abf75",
"sha256": "a3c86f722b0e54969298e5b575897c616878075d0e22a1adf519a0769aedb1c2"
},
"downloads": -1,
"filename": "htmst-1.0a9.tar.gz",
"has_sig": false,
"md5_digest": "a802d520f6d17a6f69c5132c9e2abf75",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 7084,
"upload_time": "2024-12-29T16:59:12",
"upload_time_iso_8601": "2024-12-29T16:59:12.886677Z",
"url": "https://files.pythonhosted.org/packages/d7/d9/bb3759c655792b62e834cfed207f301cf1f0886ac0f55099ae72f6e7588c/htmst-1.0a9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-29 16:59:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "picomet",
"github_project": "htmst",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "htmst"
}