hovel/pybbm — pull request #143 by DylannCordel (2014-11-17 18:55:52+00:00)
Title: Easy custom parser

Thoses modifications allow developpers to easy customize / add parsers without import / define functions in their settings.py

Old behaviour was to do this :

in settings.py :

```python
def my_complicated_parser(s):
#many hundred of very smart code lines which can depend of some modules which can not be imported in settings.py
return s

#recode the markdown and bbcode functions and all their dependencies which were defined in pybb.defaults
def bbcode(s):
#...
def markdown(s):
#...

PYBB_MARKUP_ENGINES = {
'bbcode': bbcode,
'markdown': markdown,
'great_parser':my_complicated_parser,
}
```

New behaviour :

in settings.py :

```python
PYBB_MARKUP_ENGINES = {
'bbcode': 'myapp.markup_engines.bbcode',
'markdown': 'myapp.markup_engines.markdown',
'great_parser':'myapp.markup_engines.my_complicated_parser',
}
```

in myapp.markup_engines.py :

```python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from pybb.markup_engines import PARSERS, init_bbcode_parser, init_markdown_parser, bbcode, markdown

init_bbcode_parser()
init_markdown_parser()

def my_complicated_parser(s)
#...

PARSERS['great_parser'] = my_complicated_parser
```

In pybb, we don't call anymore defaults.PYBB_MARKUP_ENGINES[defaults.PYBB_MARKUP] but util.get_markup_engine() (or if we want a specefic engine : util.get_markup_engine('great_parser')