Skip to main content

Build Status PyPI version License

HTML2PHPBBCode

HTML2PHPBBCode is a Python 3 package that can be used to parse HTML code and convert it to phpBB-compatible BBCode.

Usage

>>> from html2phpbbcode.parser import HTML2PHPBBCode
>>> parser = HTML2PHPBBCode()
>>> parser.feed('<ul><li>Hello</li><li>World</li></ul>')
'[list][*]Hello[*]World[/list]'
>>> parser.feed('<ol><li>one<li>two</ol>')
'[list=1][*]one[*]two[/list]'
>>> parser.feed('<a href="https://water.org">Water.org</a>')
'[url=https://water.org]Water.org[/url]'
>>> parser.feed('<a href="mailto:info@water.org">Mail Water.org</a>')
'[email=info@water.org]Mail Water.org[/email]'
>>> parser.feed('<strong>Hello <i>World</i>. It&#39;s a wonderful world</strong>')
"[b]Hello [i]World[/i]. It's a wonderful world[/b]"

Acknowledgements

HTML2PHPBBCode is based on the html2bbcode package of Vladimir Korsun which is available under the BSD License.

The regex package by Matthew Barnett is also used, available under the Python Software Foundation License.

The code includes some regular expressions from the phpBB bulletin board software as well. Minor changes have been made for Python compatibility. phpBB code is available under GNU GPL v2.0.

Differences from html2bbcode

This package differs from html2bbcode in the following:

  • The generated BBCode follows the syntax described in phpBB's BBCode guide.
  • <b>, <i>, <u>, <s>, <ol> HTML tags are also supported.
  • <font>'s size attribute handling has been changed so that it maps to reasonable BBCode size values.
  • If the href attribute of an <a> link uses the mailto: protocol, then the [email] BBCode tag is used.
  • If the href attribute of an <a> link is neither an email nor a valid http/https URL, the link is converted to plain-text in BBCode.
  • The parser removes excessive whitespace such as newlines between tags: <p>Hello</p>\n<p>World</p> (TODO: Use the W3C spec rules)

Installing

The package is available at PyPI and can be installed with the following command:

pip install html2phpbbcode

Installing from source is also an option:

python3 setup.py install

Testing

pytest is used for testing. Just run pytest in the project directory to execute the tests.

Release files for html2phpbbcode 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html2phpbbcode 0.2.0
File Size Uploaded
html2phpbbcode-0.2.0.tar.gz 27.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html2phpbbcode 0.2.0
File Interpreter ABI Platform
html2phpbbcode-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.0 kB

Release files / html2phpbbcode-0.2.0.tar.gz

Download URL html2phpbbcode-0.2.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9f1cdd568041c7ce8b19e5e16e54ad26e2035a233c1746d6a9e98ed71c51de9f
BLAKE2b-256 checksum
How to use checksums
0eda724546eb633e9ab5d2bb456da32eb93e28ef81add0f116aaafe9dd32c5f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / html2phpbbcode-0.2.0-py3-none-any.whl

Download URL html2phpbbcode-0.2.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
793b280a7b77bd345f5f1fac9aa5f5b5033e1ac3b12ea66e354bb62031d0b8a0
BLAKE2b-256 checksum
How to use checksums
efc8ee8748ed33eb797f2859fe6a2fc70c73fde1bdb893e83c94ec5f6dc07304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page