Page Menu
Home
Search
Configure Global Search
Log In
Files
F14216527
markdown.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
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'
,
'del'
,
'kbd'
,
'dl'
,
'dt'
,
'dd'
,
'blockquote'
,
'code'
,
'li'
,
'ol'
,
'ul'
,
'h1'
,
'h2'
,
'h3'
,
'h4'
,
'h5'
,
'h6'
,
'p'
,
'br'
,
'hr'
,
'sup'
,
'sub'
,
'strike'
,
'img'
,
'iframe'
,
]
ALLOWED_ATTRIBUTES
=
{
'a'
:
[
'href'
,
'title'
,
'target'
],
'abbr'
:
[
'title'
],
'acronym'
:
[
'title'
],
'img'
:
[
'src'
,
'alt'
,
'width'
,
'height'
,
'title'
],
'iframe'
:
[
'src'
,
'width'
,
'height'
,
'frameborder'
,
'allowfullscreen'
],
'*'
:
[
'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
Thu, Feb 2, 5:22 AM (1 d, 23 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a9/88/97d8e1a3ea486af40f32a0ba5cd6
Attached To
rPS Pillar
Event Timeline
Log In to Comment