bbcode


Namebbcode JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/dcwatson/bbcode
SummaryA pure python bbcode parser and formatter.
upload_time2019-12-31 16:10:26
maintainer
docs_urlhttps://pythonhosted.org/bbcode/
authorDan Watson
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Overview
========

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

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

**Documentation**
https://dcwatson.github.io/bbcode/

[![CI Status](https://github.com/dcwatson/bbcode/workflows/CI/badge.svg)](https://github.com/dcwatson/bbcode/actions)


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

```python
# 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](https://code.google.com/p/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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dcwatson/bbcode",
    "name": "bbcode",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/bbcode/",
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Dan Watson",
    "author_email": "dcwatson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/70/67/526c92e1c4cbba188766871c2fed76d98748c3b1d5a2028166fdd51d4204/bbcode-1.1.0.tar.gz",
    "platform": "",
    "description": "Overview\n========\n\n**Latest Package**\nhttp://pypi.python.org/pypi/bbcode\n\n**Source Code**\nhttps://github.com/dcwatson/bbcode\n\n**Documentation**\nhttps://dcwatson.github.io/bbcode/\n\n[![CI Status](https://github.com/dcwatson/bbcode/workflows/CI/badge.svg)](https://github.com/dcwatson/bbcode/actions)\n\n\nInstallation\n============\n\nThe easiest way to install the bbcode module is with pip, e.g.:\n\n    pip install bbcode\n\n\nRequirements\n============\n\nPython, tested with versions 2.7, 3.5, 3.6, 3.7, and 3.8. Also tested with PyPy (2 and 3).\n\n\nBasic Usage\n===========\n\n```python\n# Using the default parser.\nimport bbcode\nhtml = bbcode.render_html(text)\n\n# Installing simple formatters.\nparser = bbcode.Parser()\nparser.add_simple_formatter('hr', '<hr />', standalone=True)\nparser.add_simple_formatter('sub', '<sub>%(value)s</sub>')\nparser.add_simple_formatter('sup', '<sup>%(value)s</sup>')\n\n# A custom render function.\ndef render_color(tag_name, value, options, parent, context):\n    return '<span style=\"color:%s;\">%s</span>' % (tag_name, value)\n\n# Installing advanced formatters.\nfor color in ('red', 'blue', 'green', 'yellow', 'black', 'white'):\n    parser.add_formatter(color, render_color)\n\n# Calling format with context.\nhtml = parser.format(text, somevar='somevalue')\n```\n\n\nAdvantages Over [Postmarkup](https://code.google.com/p/postmarkup/)\n===================================================================\n\n* More tag options for how/when to escape - for instance, you can specify\n  whether to escape html or perform cosmetic replacements on a tag-by-tag\n  basis. Same for auto-linking and transforming newlines.\n\n* More liberal (and accurate) automatic link creation, using John Gruber's\n  URL regular expression:\n      http://daringfireball.net/2010/07/improved_regex_for_matching_urls\n\n* Does not swallow unrecognized tags. For example, [3] will be output as\n  [3], not silently ignored.\n\n* More flexible tag option parser. Tags may have standard bbcode options,\n  for example [url=something]text[/url], but may also have named options,\n  for example [url=something alt=icon]text[/url]. These options are passed\n  to the render function as a standard python dictionary.\n\n* Ability to specify tag opening and closing delimiters (default: [ and ]).\n  A side benefit of this is being able to use this library to selectively\n  strip HTML tags from a string by using < and >.\n\n* Includes a runnable unittest suite.\n\n* Python 3 support.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A pure python bbcode parser and formatter.",
    "version": "1.1.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2c6d18cdee16855ecf972c64969bb920735a4fbebb4f2b0a3b3881acb5fb7728",
                "md5": "5bda33e5d9a07d540dec719de0e443ad",
                "sha256": "83802f4b40c92426841a98350bd6ff9ea8fdf8f9b37df1968a88c5864fd225fa"
            },
            "downloads": -1,
            "filename": "bbcode-1.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5bda33e5d9a07d540dec719de0e443ad",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 11264,
            "upload_time": "2019-12-31T16:10:24",
            "upload_time_iso_8601": "2019-12-31T16:10:24.774703Z",
            "url": "https://files.pythonhosted.org/packages/2c/6d/18cdee16855ecf972c64969bb920735a4fbebb4f2b0a3b3881acb5fb7728/bbcode-1.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7067526c92e1c4cbba188766871c2fed76d98748c3b1d5a2028166fdd51d4204",
                "md5": "50eb877be1841f11f6407d38f216481b",
                "sha256": "eac4fb1d0f6c7ce5c41e4b5c0522562b15a1ac036fb9131adc59e9a28c7dc1d0"
            },
            "downloads": -1,
            "filename": "bbcode-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "50eb877be1841f11f6407d38f216481b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11136,
            "upload_time": "2019-12-31T16:10:26",
            "upload_time_iso_8601": "2019-12-31T16:10:26.326855Z",
            "url": "https://files.pythonhosted.org/packages/70/67/526c92e1c4cbba188766871c2fed76d98748c3b1d5a2028166fdd51d4204/bbcode-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-12-31 16:10:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dcwatson",
    "github_project": "bbcode",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bbcode"
}
        
Elapsed time: 0.04992s