Commit a18a95f0 by Mike Chen

convert blank lines to <br>

parent e1288eba
start
= sections:(StringResponse / NumericalResponse / MultipleChoice / Paragraph / Linebreak+)+
{
var hasKind = function(o) {
return o.hasOwnProperty('type');
}
return sections.filter(hasKind);
}
= sections:(StringResponse / NumericalResponse / MultipleChoice / Paragraph / PreservedLinebreaks)+
StudentProducedResponseIdentifier
= '='
......@@ -76,7 +70,7 @@ Paragraph
Line
= text:Text terminator:Linebreak
{
return text + terminator;
return text + '\n';
}
Text
......@@ -88,6 +82,12 @@ Text
OptionalSpaces
= ' '*
PreservedLinebreaks
= terminators:('\n')+
{
return {'type': 'linebreaks', 'count': terminators.length}
}
Linebreak
= ('\n')
......
......@@ -24,6 +24,7 @@ class @CapaDescriptor
try
source = @source_box.val() + "\n"
result = @parser.parse (source)
console.log result
@outputXML(result)
@message_box.css {"display":"none"}
catch e
......@@ -37,7 +38,8 @@ class @CapaDescriptor
dom2capa: (node) ->
capa = new XMLSerializer().serializeToString(node)
capa = capa + ""
return capa.replace(/<startouttext>/g, '<startouttext />').replace(/<\/startouttext>/g, '<endouttext />')
return capa.replace(/<startouttext>/g, '<startouttext />')
.replace(/<\/startouttext>/g, '<endouttext />')
buildXML: (parsed) ->
dom_parser = new DOMParser()
......@@ -54,6 +56,13 @@ class @CapaDescriptor
newel = create_text_element(section.text)
problem.append(newel)
else if section.type == 'linebreaks'
text = create_text_element('')
for i in [0..section.count] by 1
br = doc.createElement('br')
text.append(br)
problem.append(text)
else if section.type == 'multiple_choice'
newel = $(doc.createElement('choiceresponse'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment