| This option works together with board_markup_enabl | | This option works together with board_markup_enabl |
| ed and can be used to add | | ed and can be used to add |
| custom functions which can be used as markup. | | custom functions which can be used as markup. |
| | | |
| For example let's assume we want to create a simpl | | For example let's assume we want to create a simpl |
| e markup function which only wraps the output into | | e markup function which only wraps the output into |
| a html "pre" tag. | | a html "pre" tag. |
| | | |
n | We start by creating a function somewhere in the p | n | We start by creating a class somewhere in the pyth |
| ython path. In my example it's in sphene/custom_ma | | on path. In my example it's in sphene/custom_rende |
| rkup.py
| | rers.py (For your renderers it makes sense to put |
| | | them into your own project / application paths)
|
| | | |
n | def simplemarkup(body):
| n | from sphene.sphboard.renderers import BaseRend |
| | | erer
|
| | |
|
| | | class SimpleMarkup(BaseRenderer):
|
| | | label = 'Very Simple Markup'
|
| | | reference = '<a href="/link/to/some/docume |
| | | ntation.html">Very Simple Markup</a>'
|
| | |
|
| | | def render(self, text):
|
| return "<pre>%s</pre>" % body | | return "<pre>%s</pre>" % body |
| | | |
| Now define this markup in your settings.py: | | Now define this markup in your settings.py: |
| | | |
n | SPH_SETTINGS['board_custom_markup'] = { 'sphen | n | SPH_SETTINGS['board_custom_markup'] = { 'simpl |
| e.custom_markup.simplemarkup': 'Very simple markup | | emarkup': 'sphene.custom_renderers.SimpleMarkup', |
| ', }
| | }
|
| | | |
| (The dictionary consists of 1.) the method name in | | (The dictionary consists of 1.) the method name in |
| cluding the whole module name and 2.) a label whic | | cluding the whole module name and 2.) a label whic |
| h is displayed to the user.) | | h is displayed to the user.) |
| | | |
| To allow users to use this markup we have to enabl | | To allow users to use this markup we have to enabl |
| e it, just like any other markup using board_marku | | e it, just like any other markup using board_marku |
| p_enabled: | | p_enabled: |
| | | |
t | SPH_SETTINGS['board_markup_enabled'] = ( 'bbco | t | SPH_SETTINGS['board_markup_enabled'] = ( 'bbco |
| de', 'sphene.custom_markup.simplemarkup', ) | | de', 'simplemarkup', ) |
| | | |
| This will leave 'bbcode' as the default selection, | | This will leave 'bbcode' as the default selection, |
| but users can also select the 'Very simple markup | | but users can also select the 'Very simple markup |
| '-markup. - You can of course also define only you | | '-markup. - You can of course also define only you |
| r custom markup method if you don't want to give y | | r custom markup method if you don't want to give y |
| our users a choice. | | our users a choice. |
| | | |
| # Miscellaneous | | # Miscellaneous |
| | | |