Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
d6df7e2d
Commit
d6df7e2d
authored
Mar 01, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments to clean_message_html
parent
f8893e9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
common/lib/capa/capa/responsetypes.py
+18
-4
No files found.
common/lib/capa/capa/responsetypes.py
View file @
d6df7e2d
...
@@ -1143,19 +1143,33 @@ def sympy_check2():
...
@@ -1143,19 +1143,33 @@ def sympy_check2():
return
correct_map
return
correct_map
def
clean_message_html
(
self
,
msg
):
def
clean_message_html
(
self
,
msg
):
# If *msg* is an empty string, then the code below
# will return "</html>". To avoid this, we first check
# that *msg* is a non-empty string.
if
msg
:
if
msg
:
# try to clean up message html
# When we parse *msg* using etree, there needs to be a root
# element, so we wrap the *msg* text in <html> tags
msg
=
'<html>'
+
msg
+
'</html>'
msg
=
'<html>'
+
msg
+
'</html>'
# Replace < characters
msg
=
msg
.
replace
(
'<'
,
'<'
)
msg
=
msg
.
replace
(
'<'
,
'<'
)
#msg = msg.replace('<','<')
# Use etree to prettify the HTML
msg
=
etree
.
tostring
(
fromstring_bs
(
msg
,
convertEntities
=
None
),
msg
=
etree
.
tostring
(
fromstring_bs
(
msg
,
convertEntities
=
None
),
pretty_print
=
True
)
pretty_print
=
True
)
#msg = etree.tostring(fromstring_bs(msg),pretty_print=True)
msg
=
msg
.
replace
(
' '
,
''
)
msg
=
msg
.
replace
(
' '
,
''
)
#msg = re.sub('<html>(.*)</html>','\\1',msg,flags=re.M|re.DOTALL) # python 2.7
# Remove the <html> tags we introduced earlier, so we're
# left with just the prettified message markup
msg
=
re
.
sub
(
'(?ms)<html>(.*)</html>'
,
'
\\
1'
,
msg
)
msg
=
re
.
sub
(
'(?ms)<html>(.*)</html>'
,
'
\\
1'
,
msg
)
# Strip leading and trailing whitespace
return
msg
.
strip
()
return
msg
.
strip
()
# If we start with an empty string, then return an empty string
else
:
else
:
return
""
return
""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment