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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bbcodepy-0.2.0.tar.gz
(6.3 kB
view details)
Built Distribution
File details
Details for the file bbcodepy-0.2.0.tar.gz
.
File metadata
- Download URL: bbcodepy-0.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b68b1ce3202701cb6ed04ffb0b82232c8df8e7f0688e91caf4efc60522cb154 |
|
MD5 | 40a86466f96812498134adc6e94f1cac |
|
BLAKE2b-256 | 0b03dcdcbf3e0cce2f5dc3399a6bacdab17117cc0b1b5e72359880f94ccecd27 |
File details
Details for the file bbcodepy-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: bbcodepy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a7734bab401b88feae76458c1b3accfdf352fe2bc65656613997fb17fef654 |
|
MD5 | 7d3a2068f58a70951979945fc5fa5527 |
|
BLAKE2b-256 | 40153b3d0d8bf37f7dcfeba53c652819cca5abaf746e5ceefb648ca41399a2ca |