2
0
Fork 0
textout/textoutpc/demo/utils.py

27 lines
840 B
Python

#!/usr/bin/env python
# *****************************************************************************
# Copyright (C) 2023 Thomas Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
# *****************************************************************************
"""Utilities for the demonstration website for textoutpc."""
from __future__ import annotations
from docutils.core import publish_parts
def to_html(inputstring: str) -> str:
"""Convert textout-style BBCode to HTML.
:param inputstring: The input string to convert.
:return: The produced HTML.
"""
parts = publish_parts(
inputstring,
source_path="<stdin>",
destination_path="<stdout>",
parser_name="textoutpc",
writer_name="textoutpc.html",
)
return parts["body"]