Skip to content

Commit

Permalink
Merge branch 'master' into ignore-malformed-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Alir3z4 authored Dec 22, 2023
2 parents 290d948 + 099c4b8 commit 4157f6f
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 47 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
code-quality:
runs-on: ubuntu-latest
strategy:
matrix:
toxenv:
- black
- flake8
- mypy
- isort
env:
TOXENV: ${{ matrix.toxenv }}

name: "Tox ${{ matrix.toxenv }}"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install Requirements [${{ matrix.toxenv }}]
run: pip install tox

- name: Tox-${{ matrix.toxenv }}
run: tox
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
toxenv:
- py38
- py39
- py310
include:
- toxenv: py38
python-version: '3.8'
- toxenv: py39
python-version: '3.9'
- toxenv: py310
python-version: '3.10'
- toxenv: py311
python-version: '3.11'
- toxenv: py312
python-version: '3.12'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOXENV: ${{ matrix.toxenv }}
name: "Python ${{ matrix.python-version }} | Tox ${{ matrix.toxenv }}"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 2

- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Requirements [Python-${{ matrix.python-version }}]
run: pip install tox

- name: Tox-${{ matrix.toxenv }}
run: tox

- name: Upload coverage to Codecov
# see https://github.com/codecov/codecov-action/blob/master/README.md
uses: codecov/codecov-action@v2
with:
flags: unittests-${{ matrix.python-version }}
fail_ci_if_error: true # default = false
os: toxenv
verbose: true # default = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dist
.idea
.coverage
.coverage.*
coverage.xml
env/
.c9/
.vscode
Expand Down
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ UNRELEASED
* Fix #344: indent ``<ul>`` inside ``<ol>`` three spaces instead of two to comply with CommonMark, GFM, etc.
* Fix #324: unnecessary spaces around ``<b>``, ``<em>``, and ``strike`` tags.
* Don't wrap tables by default and add a ``--wrap-tables`` config option
* Remove support for Python ≤ 3.5. Now requires Python 3.6+.
* Support for Python 3.10.
* Fix #320 padding empty tables and tables with no </tr> tags.
* Add ``ignore_mailto_links`` config option to ignore ``mailto:`` style links.



2020.1.16
=========
----
Expand Down
5 changes: 2 additions & 3 deletions html2text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def feed(self, data: str) -> None:
super().feed(data)

def handle(self, data: str) -> str:
self.start = True
self.feed(data)
self.feed("")
markdown = self.optwrap(self.finish())
Expand Down Expand Up @@ -372,9 +373,7 @@ def handle_tag(
self.p()

if tag == "br" and start:
if self.astack:
self.space = True
elif self.blockquote > 0:
if self.blockquote > 0:
self.o(" \n> ")
else:
self.o(" \n")
Expand Down
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Expand All @@ -30,7 +29,7 @@ platform = OS Independent
[options]
zip_safe = False
packages = html2text
python_requires = >=3.5
python_requires = >=3.7

[options.entry_points]
console_scripts =
Expand All @@ -48,4 +47,4 @@ combine_as_imports = True
profile = black

[mypy]
python_version = 3.5
python_version = 3.7
1 change: 0 additions & 1 deletion test/br_inside_a.html

This file was deleted.

1 change: 0 additions & 1 deletion test/br_inside_a.md

This file was deleted.

12 changes: 12 additions & 0 deletions test/test_newlines_on_multiple_calls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import html2text

# See https://github.com/Alir3z4/html2text/issues/163 for more information.


def test_newline_on_multiple_calls():
h = html2text.HTML2Text()
html = "<p>test</p>"
md1 = h.handle(html)
md2 = h.handle(html)
md3 = h.handle(html)
assert md1 == md2 == md3
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ envlist =
flake8
isort
mypy
py{35,36,37,38,py3}
minversion = 1.9
py{38,39,310,311,312}
minversion = 3.24

[testenv]
commands =
pytest --cov=html2text {posargs}
pytest --cov=./ --cov-report=xml {posargs}
deps =
pytest
pytest-cov

[testenv:black]
basepython = python3
commands =
black --target-version py35 --check --diff .
black --target-version py311 --check --diff .
deps =
black
skip_install = true
Expand All @@ -35,7 +35,7 @@ basepython = python3
commands =
isort --check-only --diff .
deps =
isort >= 5.0.1
isort >= 5.10.1
skip_install = true

[testenv:mypy]
Expand Down

0 comments on commit 4157f6f

Please sign in to comment.