Skip to content

Commit

Permalink
note scripts: can have an empty line in a note if the next line start…
Browse files Browse the repository at this point in the history
…s with a space

An annoying problem when writing marking or diagnostic algorithms was
that you couldn't put an empty line in something like a big `let` call:

note_1:
    let(
        a, 1,
        b, 2,

        a+b
    )

note_2:
    note_1

This commit changes the regex so that the next thing after the two line
breaks must be a non-space character, i.e. the next line after the gap
must not be indented.

This allows gaps inside expressions like the one above, where the next
line after the gap is indented.
  • Loading branch information
christianp committed Dec 3, 2024
1 parent 2dd1a1d commit 2422a75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/scripts/jme-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ jme.variables.note_script_constructor = function(construct_scope, process_result
this.source = source;
scope = construct_scope(scope || Numbas.jme.builtinScope);
try {
var notes = source.split(/\n(\s*\n)+/);
var notes = source.replace(/^\/\/.*$/gm,'').split(/\n(?:\s*\n)+(?!\s)/);
var ntodo = {};
var todo = {};
notes.forEach(function(note) {
Expand Down

0 comments on commit 2422a75

Please sign in to comment.