Skip to content

Repository files navigation

Overview

Latest Packagehttp://pypi.python.org/pypi/bbcode

Source Codehttps://github.com/dcwatson/bbcode

Documentationhttps://dcwatson.github.io/bbcode/

CI Status

Installation

The easiest way to install the bbcode module is with pip, e.g.:

pip install bbcode

Requirements

Python 3.9+

Basic Usage

# Using the default parser.importbbcodehtml=bbcode.render_html(text)
# Installing simple formatters.parser=bbcode.Parser()
parser.add_simple_formatter('hr', '<hr />', standalone=True)
parser.add_simple_formatter('sub', '<sub>%(value)s</sub>')
parser.add_simple_formatter('sup', '<sup>%(value)s</sup>')
# A custom render function.defrender_color(tag_name, value, options, parent, context):
return'<span style="color:%s;">%s</span>'% (tag_name, value)
# Installing advanced formatters.forcolorin ('red', 'blue', 'green', 'yellow', 'black', 'white'):
parser.add_formatter(color, render_color)
# Calling format with context.html=parser.format(text, somevar='somevalue')

About

A pure python bbcode parser and formatter.

Topics

Resources

Stars

73 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages