Skip to main content

Overview

Latest Package http://pypi.python.org/pypi/bbcode

Source Code https://github.com/dcwatson/bbcode

Documentation https://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, tested with versions 2.7, 3.5, 3.6, 3.7, and 3.8. Also tested with PyPy (2 and 3).

Basic Usage

# Using the default parser.
import bbcode
html = 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.
def render_color(tag_name, value, options, parent, context):
    return '<span style="color:%s;">%s</span>' % (tag_name, value)

# Installing advanced formatters.
for color in ('red', 'blue', 'green', 'yellow', 'black', 'white'):
    parser.add_formatter(color, render_color)

# Calling format with context.
html = parser.format(text, somevar='somevalue')

Advantages Over Postmarkup

  • More tag options for how/when to escape - for instance, you can specify whether to escape html or perform cosmetic replacements on a tag-by-tag basis. Same for auto-linking and transforming newlines.

  • More liberal (and accurate) automatic link creation, using John Gruber's URL regular expression: http://daringfireball.net/2010/07/improved_regex_for_matching_urls

  • Does not swallow unrecognized tags. For example, [3] will be output as [3], not silently ignored.

  • More flexible tag option parser. Tags may have standard bbcode options, for example [url=something]text[/url], but may also have named options, for example [url=something alt=icon]text[/url]. These options are passed to the render function as a standard python dictionary.

  • Ability to specify tag opening and closing delimiters (default: [ and ]). A side benefit of this is being able to use this library to selectively strip HTML tags from a string by using < and >.

  • Includes a runnable unittest suite.

  • Python 3 support.

Release files for bbcode 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bbcode 1.1.0
File Size Uploaded
bbcode-1.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bbcode 1.1.0
File Interpreter ABI Platform
bbcode-1.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 22.4 kB

Release files / bbcode-1.1.0.tar.gz

Download URL bbcode-1.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eac4fb1d0f6c7ce5c41e4b5c0522562b15a1ac036fb9131adc59e9a28c7dc1d0
BLAKE2b-256 checksum
How to use checksums
7067526c92e1c4cbba188766871c2fed76d98748c3b1d5a2028166fdd51d4204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.0 setuptools/38.5.2 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14

Release files / bbcode-1.1.0-py2.py3-none-any.whl

Download URL bbcode-1.1.0-py2.py3-none-any.whl
Size 11.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
83802f4b40c92426841a98350bd6ff9ea8fdf8f9b37df1968a88c5864fd225fa
BLAKE2b-256 checksum
How to use checksums
2c6d18cdee16855ecf972c64969bb920735a4fbebb4f2b0a3b3881acb5fb7728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.0 setuptools/38.5.2 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.33

1 release file

1.0.32

1 release file

1.0.31

1 release file

1.0.30

1 release file

1.0.29

1 release file

1.0.28

1 release file

1.0.27

1 release file

1.0.26

1 release file

1.0.25

1 release file

1.0.24

1 release file

1.0.23

1 release file

1.0.22

1 release file

1.0.21

1 release file

1.0.20

1 release file

1.0.19

1 release file

1.0.18

1 release file

1.0.17

1 release file

1.0.16

1 release file

1.0.15

1 release file

1.0.14

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page