htmst


Namehtmst JSON
Version 1.0a1 PyPI version JSON
download
home_pageNone
SummaryHTML to AST with positions
upload_time2024-11-24 08:54:16
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
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

-   `TextNode`: represents texts
-   `AttrNode`: represents attributes
-   `DoubleNode`: represents double tags
-   `SingleNode`: represents single tags
-   `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/1a/65/b86a505264baab111c9c9243e90671d43e7a01196e65a72a6b63bd3cef61/htmst-1.0a1.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-   `TextNode`: represents texts\n-   `AttrNode`: represents attributes\n-   `DoubleNode`: represents double tags\n-   `SingleNode`: represents single tags\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.0a1",
    "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": "b38960ffb33d75c12bbec72b6a81acb530009924e573c9f032771fa069ea319a",
                "md5": "523a49004de048241cbb94d52cb3c5b3",
                "sha256": "0bdbae05ac0cbbcd8856e52b895c7b0a1f992ab2b19dc360d31f716727649d43"
            },
            "downloads": -1,
            "filename": "htmst-1.0a1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "523a49004de048241cbb94d52cb3c5b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 5676,
            "upload_time": "2024-11-24T08:54:15",
            "upload_time_iso_8601": "2024-11-24T08:54:15.210522Z",
            "url": "https://files.pythonhosted.org/packages/b3/89/60ffb33d75c12bbec72b6a81acb530009924e573c9f032771fa069ea319a/htmst-1.0a1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a65b86a505264baab111c9c9243e90671d43e7a01196e65a72a6b63bd3cef61",
                "md5": "f2fefae2e0c6d8ef612a0404bd612483",
                "sha256": "fb4b8c4b5575e6b234d058d5f3420b9822258965b72bcd07adf270cde0a2651c"
            },
            "downloads": -1,
            "filename": "htmst-1.0a1.tar.gz",
            "has_sig": false,
            "md5_digest": "f2fefae2e0c6d8ef612a0404bd612483",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 6704,
            "upload_time": "2024-11-24T08:54:16",
            "upload_time_iso_8601": "2024-11-24T08:54:16.969131Z",
            "url": "https://files.pythonhosted.org/packages/1a/65/b86a505264baab111c9c9243e90671d43e7a01196e65a72a6b63bd3cef61/htmst-1.0a1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-24 08:54:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "picomet",
    "github_project": "htmst",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "htmst"
}
        
Elapsed time: 0.81943s