Skip to main content

Python Library for rendering BBCode.

Project description

BBCODEPY

bbcodepy is a fast Python BBCode parser and renderer.

Usage

All common BBCode tags are supported by default.

import bbcodepy
print bbcodepy.Parser().to_html('[b]Hello![/b]')

Easily add new tags!

import bbcodepy

class YoutubeTag(bbcodepy.Tag):
    def to_html(self):
        attributes = {
            'src': self.get_content(True).strip(),
            'width': self.params.get('width', 420),
            'height': self.params.get('height', 315)
        }

        return '<iframe %s frameborder="0" allowfullscreen></iframe>' % self.renderer.html_attributes(attributes)

parser = bbcodepy.Parser()
parser.register_tag('youtube', YoutubeTag)

print parser.to_html('[youtube width=420 height=315]http://www.youtube.com/embed/rWTa6OKgWlM[/youtube]')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bbcodepy, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size bbcodepy-0.2.0-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size bbcodepy-0.2.0.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page