Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ jobs:

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
print-hash: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/html2text/_version.py

*.py[co]
*.bak
build
Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,41 @@ Hello, [world](https://www.google.com/earth/)!
`html2text` is available on pypi
https://pypi.org/project/html2text/

```
```shell
$ pip install html2text
```

## Development

## How to run unit tests
### How to run unit tests

tox
```shell
$ tox
```

To see the coverage results:

coverage html
```shell
$ coverage html
```

then open the `./htmlcov/index.html` file in your browser.


### Code Quality & Pre Commit

The CI runs several linting steps, including:

- mypy
- Flake8
- Black

To make sure the code passes the CI linting steps, run:

```shell
$ tox -e pre-commit
```

## Documentation

Documentation lives [here](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md)
6 changes: 3 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ $ pip install html2text
Clone the repository from https://github.com/Alir3z4/html2text

```
$ git clone --depth 1 https://github.com/Alir3z4/html2text.git
$ python setup.py build
$ python setup.py install
$ git clone --depth 50 https://github.com/Alir3z4/html2text.git
$ python -m build -nwx
$ python -m pip install --upgrade ./dist/*.whl
```


Expand Down
4 changes: 2 additions & 2 deletions html2text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from . import config
from ._typing import OutCallback
from ._version import __version_tuple__
from .elements import AnchorElement, ListElement
from .utils import (
control_character_replacements,
Expand All @@ -28,8 +29,7 @@
unifiable_n,
)

__version__ = (2024, 2, 26)

__version__ = __version_tuple__

# TODO:
# Support decoded entities with UNIFIABLE.
Expand Down
3 changes: 2 additions & 1 deletion html2text/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import sys

from . import HTML2Text, __version__, config
from . import HTML2Text, config
from ._version import __version_tuple__ as __version__


def main() -> None:
Expand Down
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta"

[project]
name = "html2text"
description = "Turn HTML into equivalent Markdown-structured text."
readme = "README.md"
authors = [{name = "Aaron Swartz", email = "me@aaronsw.com"}]
maintainers = [{name = "Alireza Savand", email = "alireza.savand@gmail.com"}]
license = "GPL-3.0-or-later"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
urls = {Homepage = "https://github.com/Alir3z4/html2text/"}
requires-python = ">=3.9"
dynamic = ["version"]

[project.scripts]
html2text = "html2text.cli:main"

[tool.setuptools]
zip-safe = false
packages = ["html2text"]
platforms = ["OS Independent"]
include-package-data = false

[tool.setuptools.package-data]
html2text = ["py.typed"]

[tool.setuptools_scm]
write_to = "html2text/_version.py"

[tool.black]
line-length = 88
target-version = ['py313']
extend-exclude = '''
/(
html2text/_version.py
)
'''

[tool.flake8] # you will need Flake8-pyproject
max_line_length = "88"
extend-ignore = "E203"

[tool.isort]
profile = "black"
combine_as_imports = true
extend_skip = ["html2text/_version.py"]

[tool.mypy]
python_version = "3.9"
53 changes: 0 additions & 53 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

28 changes: 18 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,37 @@ setenv =

[testenv:black]
basepython = python3
commands =
black --target-version py38 --line-length 88 --check --diff .
deps =
black
commands = black --check --diff .
deps = black
skip_install = true

[testenv:flake8]
basepython = python3
commands =
flake8 --max-line-length 88
commands = flake8
deps =
flake8
Flake8-pyproject
skip_install = true

[testenv:isort]
basepython = python3
commands =
isort --check-only --diff .
deps =
isort
commands = isort --check-only --diff .
deps = isort
skip_install = true

[testenv:mypy]
commands = mypy --strict html2text
deps = mypy

[testenv:pre-commit]
basepython = python3
commands =
isort --atomic .
flake8
black .
deps =
isort
flake8
Flake8-pyproject
black
skip_install = true