Page Menu
Home
Search
Configure Global Search
Log In
Files
F9590773
markdown.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
918 B
Subscribers
None
markdown.py
View Options
"""Bleached Markdown functionality.
This is for user-generated stuff, like comments.
"""
from
__future__
import
absolute_import
import
bleach
import
markdown
as
_markdown
ALLOWED_TAGS
=
[
'a'
,
'abbr'
,
'acronym'
,
'b'
,
'strong'
,
'i'
,
'em'
,
'blockquote'
,
'code'
,
'li'
,
'ol'
,
'ul'
,
'h1'
,
'h2'
,
'h3'
,
'h4'
,
'h5'
,
'h6'
,
'p'
,
'img'
,
]
ALLOWED_ATTRIBUTES
=
{
'a'
:
[
'href'
,
'title'
,
'target'
],
'abbr'
:
[
'title'
],
'acronym'
:
[
'title'
],
'img'
:
[
'src'
,
'alt'
,
'width'
,
'height'
,
'title'
],
'*'
:
[
'style'
],
}
ALLOWED_STYLES
=
[
'color'
,
'font-weight'
,
'background-color'
,
]
def
markdown
(
s
):
tainted_html
=
_markdown
.
markdown
(
s
)
safe_html
=
bleach
.
clean
(
tainted_html
,
tags
=
ALLOWED_TAGS
,
attributes
=
ALLOWED_ATTRIBUTES
,
styles
=
ALLOWED_STYLES
)
return
safe_html
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sat, Jan 23, 11:54 AM (1 d, 23 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d8/96/942ae59c67c495b5ba85d9e16039
Attached To
rPS Pillar
Event Timeline
Log In to Comment