Humanfriendly

Latest version: v10.0

Safety actively analyzes 682404 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 23

4.16

----------------------------

More HTML to ANSI improvements:

- Added :func:`humanfriendly.text.compact_empty_lines()` function.
- Enable optional ``callback`` argument to
:func:`humanfriendly.terminal.html_to_ansi()`.
- Added a code sample and screenshot to the
:class:`humanfriendly.terminal.HTMLConverter` documentation.
- Emit vertical whitespace for block tags like ``<div>``, ``<p>`` and ``<pre>``
and post-process the generated output in ``__call__()`` to compact empty lines.
- Don't pre-process preformatted text using the user defined text callback.
- Improve robustness against malformed HTML (previously an ``IndexError`` would
be raised when a closing ``</a>`` tag was encountered without a corresponding
opening ``<a>`` tag).
- Emit an ANSI reset code when :func:`humanfriendly.terminal.html.HTMLConverter.close()`
is called and a style is still active (improves robustness against malformed HTML).

.. _Release 4.16: https://github.com/xolox/python-humanfriendly/compare/4.15.1...4.16

4.15.1

------------------------------

Bug fixes for HTML to ANSI conversion.

HTML entities were being omitted from conversion because I had neglected to
define the ``handle_charref()`` and ``handle_entityref()`` methods (whose
definitions are so conveniently given in the documentation of the
``HTMLParser`` class 😇).

.. _Release 4.15.1: https://github.com/xolox/python-humanfriendly/compare/4.15...4.15.1

4.15

----------------------------

Added the :func:`humanfriendly.terminal.html_to_ansi()` function which is a
shortcut for the :class:`humanfriendly.terminal.HTMLConverter` class that's
based on ``html.parser.HTMLParser``.

This new functionality converts HTML with simple text formatting tags like
``<b>`` for bold, ``<i>`` for italic, ``<u>`` for underline, ``<span>`` for
colors, etc. to text with ANSI escape sequences.

I'm still working on that awesome new project (update: see chat-archive_), this
functionality was born there but seemed like a useful addition to the
``humanfriendly`` package, given the flexibility that this provides 😇.

.. _Release 4.15: https://github.com/xolox/python-humanfriendly/compare/4.14...4.15

4.14

----------------------------

Support for 24-bit (RGB) terminal colors. Works by accepting a tuple or
list with three integers representing an RGB (red, green, blue) color.

.. _Release 4.14: https://github.com/xolox/python-humanfriendly/compare/4.13...4.14

4.13

----------------------------

Support for *italic* text rendering on the terminal.

I'm working on an awesome new project (update: see chat-archive_) that's almost
ready to publish, but then I noticed that I couldn't render italic text on the
terminal using the humanfriendly package. I checked and sure enough my terminal
supported it just fine, so I didn't see any reason not to fix this now 😇.

.. _Release 4.13: https://github.com/xolox/python-humanfriendly/compare/4.12.1...4.13
.. _chat-archive: https://chat-archive.readthedocs.io/

4.12.1

------------------------------

It was reported in issue `28`_ that ``humanfriendly --demo`` didn't work
on Python 3 due to two unrelated ``TypeError`` exceptions. First I added
a failing regression test to the test suite (`here's the failing build
<https://travis-ci.org/xolox/python-humanfriendly/builds/377202561>`_)
and then I applied the changes suggested in issue `28`_, confirming that both
issues are indeed fixed because the test now passes (`here's the successful
build <https://travis-ci.org/xolox/python-humanfriendly/builds/377203446>`_).

.. _Release 4.12.1: https://github.com/xolox/python-humanfriendly/compare/4.12...4.12.1
.. _28: https://github.com/xolox/python-humanfriendly/issues/28

Page 4 of 23

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.