Page Menu
Home
Search
Configure Global Search
Log In
Files
F13353178
markdown.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
910 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
CommonMark
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
=
CommonMark
.
commonmark
(
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
Fri, Aug 12, 10:56 AM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d1/50/bbb5e171938e9fba133743a2f3c9
Attached To
rPS Pillar
Event Timeline
Log In to Comment