A pure Python markup converter supporting creole2html, html2creole, html2ReSt, and html2textile conversions
npx @tessl/cli install tessl/pypi-python-creole@1.4.0A pure Python markup converter that enables seamless conversion between different markup formats. python-creole provides bidirectional conversion capabilities for Creole markup, HTML, ReStructuredText, and Textile, making it essential for documentation systems, content management, and markup processing workflows.
pip install python-creoleimport creoleCommon conversion functions:
from creole import creole2html, html2creole, html2rest, html2textileReStructuredText to HTML conversion:
from creole.rest_tools.clean_writer import rest2htmlfrom creole import creole2html, html2creole, html2rest, html2textile
# Convert Creole markup to HTML
creole_markup = "This is **bold** and //italic// text"
html_output = creole2html(creole_markup)
print(html_output) # <p>This is <strong>bold</strong> and <i>italic</i> text</p>
# Convert HTML back to Creole
html_input = '<p>This is <strong>bold</strong> and <i>italic</i> text</p>'
creole_output = html2creole(html_input)
print(creole_output) # This is **bold** and //italic// text
# Convert HTML to ReStructuredText
rest_output = html2rest(html_input)
print(rest_output) # This is **bold** and *italic* text
# Convert HTML to Textile
textile_output = html2textile(html_input)
print(textile_output) # This is *bold* and __italic__ textpython-creole uses a document tree-based conversion architecture:
This design enables clean separation between parsing and output generation, allowing flexible conversion between any supported markup formats while maintaining structural integrity.
Primary markup conversion functions for transforming between Creole, HTML, ReStructuredText, and Textile formats. These functions handle the most common conversion scenarios with sensible defaults.
def creole2html(markup_string: str, debug: bool = False,
parser_kwargs: dict = None, emitter_kwargs: dict = None,
block_rules: tuple = None, blog_line_breaks: bool = True,
macros: dict = None, verbose: int = None, stderr = None,
strict: bool = False) -> str: ...
def html2creole(html_string: str, debug: bool = False,
parser_kwargs: dict = None, emitter_kwargs: dict = None,
unknown_emit = None, strict: bool = False) -> str: ...
def html2rest(html_string: str, debug: bool = False,
parser_kwargs: dict = None, emitter_kwargs: dict = None,
unknown_emit = None) -> str: ...
def html2textile(html_string: str, debug: bool = False,
parser_kwargs: dict = None, emitter_kwargs: dict = None,
unknown_emit = None) -> str: ...
def parse_html(html_string: str, debug: bool = False) -> DocNode: ...Clean HTML generation from ReStructuredText markup with minimal output formatting, designed for use in documentation systems and web publishing workflows.
def rest2html(content: str, enable_exit_status: bool = None, **kwargs) -> str: ...Low-level classes for advanced parsing and emission control, enabling custom conversion workflows and specialized markup processing.
class CreoleParser:
def __init__(self, markup_string: str, **kwargs): ...
def parse(self) -> DocNode: ...
class HtmlParser:
def __init__(self, debug: bool = False): ...
def feed(self, html_string: str) -> DocNode: ...
class HtmlEmitter:
def __init__(self, document: DocNode, **kwargs): ...
def emit(self) -> str: ...
class CreoleEmitter:
def __init__(self, document: DocNode, debug: bool = False, **kwargs): ...
def emit(self) -> str: ...Parsers and Emitters - includes HTML utilities and unknown tag handlers
Built-in macros for extended functionality including syntax highlighting and raw HTML inclusion, plus utilities for creating custom macros.
def html(text: str) -> str: ...
def pre(text: str) -> str: ...
def code(ext: str, text: str) -> str: ...Helper functions for project setup, README generation, and development workflows, including conversion from Creole to ReStructuredText for PyPI compatibility.
def get_long_description(package_root: str, filename: str = 'README.creole',
raise_errors: bool = None) -> str: ...
def update_rst_readme(package_root: str, filename: str = 'README.creole') -> None: ...
def assert_rst_readme(package_root: str, filename: str = 'README.creole') -> None: ...Command-line tools for file-based markup conversion with support for different text encodings and batch processing.
class CreoleCLI:
def __init__(self, convert_func): ...
def convert(self, sourcefile: str, destination: str, encoding: str): ...CLI Commands:
creole2html - Convert creole files to HTMLhtml2creole - Convert HTML files to creolehtml2rest - Convert HTML files to ReStructuredTexthtml2textile - Convert HTML files to textileclass DocNode:
def __init__(self, kind: str = None, parent=None): ...
def debug(self): ...
def append(self, child): ...
def get_text(self) -> str: ...
def get_attrs_as_string(self) -> str: ...
class DocutilsImportError(ImportError):
pass
class Html2restException(Exception):
pass
# HTML entity decoder class
class Deentity:
def __init__(self): ...
def replace_all(self, content: str) -> str: ...
# Handler function type for unknown HTML tags
UnknownTagHandler = Callable[[BaseEmitter, DocNode], str]
# Macro function types
MacroFunction = Callable[[str], str]
MacroWithArgs = Callable[[str, str], str]__version__: str = "1.4.10"
__api__: str = "1.0" # Creole 1.0 specification compatibility
VERSION_STRING: str # Deprecated alias for __version__
API_STRING: str # Deprecated alias for __api__