Commit 8245ebac by Don Mitchell

On menu based markdown conversion,

	be picky about x as marker for correct requiring it to be first
non-whitespace char on line, followed by whitespace, followed eventually
but another non-whitespace char
 	strip trailing newline from selection.
parent 144c6bca
......@@ -125,25 +125,19 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
@insertGenericChoice: (selectedText, choiceStart, choiceEnd, template) ->
if selectedText.length > 0
# Replace adjacent newlines with a single newline
cleanSelectedText = selectedText.replace(/\n+/g, '\n')
# Replace adjacent newlines with a single newline, strip any trailing newline
cleanSelectedText = selectedText.replace(/\n+/g, '\n').replace(/\n$/,'')
lines = cleanSelectedText.split('\n')
revisedLines = ''
for line in lines
revisedLines += choiceStart
# This is looking for a x before text to mark as selected.
if /x\s/i.test(line)
# Remove the x and any initial whitespace
lineWithoutX = line.replace(/^(\s+)?x/i, '')
# Check if any non-whitespace chars remain on the line
if not /^\s+$/.test(lineWithoutX)
# Remove initial whitespace, x, and space immediately after
line = line.replace(/^(\s+)?x\s/i, '')
# a stand alone x before other text implies that this option is "correct"
if /^\s*x\s*(\S)/i.test(line)
# Remove the x and any initial whitespace as long as there's more text on the line
line = line.replace(/^\s*x\s*(\S)/i, '$1')
revisedLines += 'x'
else
revisedLines += ' '
else
revisedLines += ' '
revisedLines += choiceEnd + ' ' + line + '\n'
return revisedLines
else
......
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