Rendering BBCode as HTML#

In order to render BBCode as HTML, you can use the render_as_html() function. For example:

from __future__ import annotations

from textoutpc import render_as_html

text = """\
[img=center]https://www.planet-casio.com/assets/img/logo.png[/img]

Hello [color=R10]world[/color]!
[list]
[li]This module is made by [url=https://thomas.touhey.fr/]me[/url]!
[li]Use `render_as_html()` to translate magically to HTML!
[/]
"""

print(render_as_html(text), end="")

This will print the following in the console:

<img class="img-center" src="https://www.planet-casio.com/assets/img/logo.png">

Hello <span style="color: #FF1A00; color: hwb(6deg, 0%, 0%)">world</span>!
<ul><li>This module is made by <a href="https://thomas.touhey.fr/" target="_blank" rel="noopener">me</a>!</li><li>Use <span style="font-family: monospace">render_as_html()</span> to translate magically to HTML!</li></ul>