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
ef134df8
Commit
ef134df8
authored
Jul 03, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the HTML module to use the lxml HTML parser when parsing html file includes
parent
2223aaa6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
+17
-1
common/lib/xmodule/xmodule/html_module.py
+6
-0
common/lib/xmodule/xmodule/xml_module.py
+11
-1
No files found.
common/lib/xmodule/xmodule/html_module.py
View file @
ef134df8
import
logging
from
lxml
import
etree
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
...
...
@@ -26,3 +27,8 @@ class HtmlDescriptor(RawDescriptor):
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/module/html.coffee'
)]}
js_module
=
'HTML'
@classmethod
def
file_to_xml
(
cls
,
file_object
):
parser
=
etree
.
HTMLParser
()
return
etree
.
parse
(
file_object
,
parser
)
.
getroot
()
common/lib/xmodule/xmodule/xml_module.py
View file @
ef134df8
...
...
@@ -91,6 +91,16 @@ class XmlDescriptor(XModuleDescriptor):
del
xml_object
.
attrib
[
attr
]
@classmethod
def
file_to_xml
(
cls
,
file_object
):
"""
Used when this module wants to parse a file object to xml
that will be converted to the definition.
Returns an lxml Element
"""
return
etree
.
parse
(
file_object
)
.
getroot
()
@classmethod
def
from_xml
(
cls
,
xml_data
,
system
,
org
=
None
,
course
=
None
):
"""
Creates an instance of this descriptor from the supplied xml_data.
...
...
@@ -127,7 +137,7 @@ class XmlDescriptor(XModuleDescriptor):
filepath
=
cls
.
_format_filepath
(
xml_object
.
tag
,
filename
)
with
system
.
resources_fs
.
open
(
filepath
)
as
file
:
try
:
definition_xml
=
etree
.
parse
(
file
)
.
getroot
(
)
definition_xml
=
cls
.
file_to_xml
(
file
)
except
:
log
.
exception
(
"Failed to parse xml in file
%
s"
%
filepath
)
raise
...
...
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