Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked how comments and text are being rendered to be more flexible…
… for user expansion.
- Loading branch information
Showing
7 changed files
with
76 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
This file contains filters which are used for pre and post | ||
processing various kinds of text within LifeFlow. | ||
Which values are applied is controlled by a number of global | ||
variables within the project's settings.py file. These vars | ||
are: | ||
LIFEFLOW_ENTRY_FILTERS | ||
LIFEFLOW_COMMENT_FILTERS | ||
If you wish to add your own filters, you don't | ||
have to add them to this file, they can exist anywhere, and | ||
simply import them into the settings.py file and add them | ||
to the appropriate global variable. | ||
The API for these processing functions is very simple: | ||
they accept two parameters, a string to process, | ||
and optionally a related model. | ||
""" | ||
|
||
import cgi, re | ||
from django.conf import settings | ||
from lifeflow.markdown.markdown import Markdown | ||
from lifeflow.markdown import mdx_lifeflow | ||
from lifeflow.markdown import mdx_code | ||
from lifeflow.markdown import mdx_footnotes | ||
from lifeflow.markdown import mdx_foreign_formats | ||
|
||
|
||
|
||
def comment_markup(txt,obj=None): | ||
filters = getattr(settings,'LIFEFLOW_COMMENT_FILTERS', DEFAULT_COMMENT_FILTERS) | ||
for filter in filters: | ||
txt = filter(txt) | ||
return txt | ||
|
||
def entry_markup(txt,obj=None): | ||
filters = getattr(settings,'LIFEFLOW_ENTRY_FILTERS', DEFAULT_ENTRY_FILTERS) | ||
for filter in filters: | ||
txt = filter(txt) | ||
return txt | ||
|
||
|
||
def comment_markdown(txt,obj=None): | ||
exts = (mdx_code,) | ||
md = Markdown(txt,extensions=exts,safe_mode=True) | ||
return md.convert() | ||
|
||
|
||
def entry_markdown(txt,obj=None): | ||
exts = (mdx_code, mdx_footnotes,mdx_foreign_formats, mdx_lifeflow) | ||
md = Markdown(txt,extensions=exts,extension_configs={'lifeflow':obj}) | ||
return md.convert() | ||
|
||
|
||
DEFAULT_COMMENT_FILTERS = (comment_markdown,) | ||
DEFAULT_ENTRY_FILTERS = (entry_markdown,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters