or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdcore-conversions.mdindex.mdmacros-extensions.mdparsers-emitters.mdrest-tools.mdsetup-utilities.md
tile.json

tessl/pypi-python-creole

A pure Python markup converter supporting creole2html, html2creole, html2ReSt, and html2textile conversions

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/python-creole@1.4.x

To install, run

npx @tessl/cli install tessl/pypi-python-creole@1.4.0

index.mddocs/

Python-Creole

A 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.

Package Information

  • Package Name: python-creole
  • Language: Python
  • Installation: pip install python-creole
  • License: GPL-3.0-or-later
  • Python Support: 3.6+, PyPy3

Core Imports

import creole

Common conversion functions:

from creole import creole2html, html2creole, html2rest, html2textile

ReStructuredText to HTML conversion:

from creole.rest_tools.clean_writer import rest2html

Basic Usage

from 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__ text

Architecture

python-creole uses a document tree-based conversion architecture:

  • Parsers: Convert input markup into intermediate document tree representation
  • Document Tree: Node-based structure representing markup elements and hierarchy
  • Emitters: Generate output markup from document tree
  • Handlers: Process special cases like unknown tags, macros, and formatting rules

This design enables clean separation between parsing and output generation, allowing flexible conversion between any supported markup formats while maintaining structural integrity.

Capabilities

Core Conversion Functions

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: ...

Core Conversions

ReStructuredText Tools

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: ...

ReStructuredText Tools

Parsers and Emitters

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

Macros and Extensions

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: ...

Macros and Extensions

Setup and Utilities

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: ...

Setup and Utilities

Command Line Interface

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 HTML
  • html2creole - Convert HTML files to creole
  • html2rest - Convert HTML files to ReStructuredText
  • html2textile - Convert HTML files to textile

Command Line Interface

Types

class 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]

Constants

__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__