def parse_xml(cls, node, runtime, keys, id_generator):
"""
Parses the source XML in a way that preserves indenting, needed for markdown.
"""
block = runtime.construct_xblock_from_class(cls, keys)
# Load the data
for name, value in node.items():
if name in block.fields:
value = (block.fields[name]).from_string(value)
setattr(block, name, value)
# Load content
text = node.text
if text:
# Fix up whitespace.
if text[0] == "\n":
text = text[1:]
text.rstrip()
text = textwrap.dedent(text)
if text:
block.content = text
return block
评论列表
文章目录