Skip to content

Commit 71bd729

Browse files
authored
Merge pull request #1551 from wilzbach/ddox-writeln-rewrite-magic
Ddox: support assert to writeln rewrite
2 parents 2d41071 + 7e75b64 commit 71bd729

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

js/run.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ function setupTextarea(el, opts)
576576
}
577577
});
578578
});
579+
return editor;
579580
};
580581

581582

js/run_examples.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// turns asserts into writeln
1010
function reformatExample(code) {
11-
return code.replace(/(<span class="d_keyword">assert<\/span>\((.*)==(.*)\);)+/g, function(match, text, left, right) {
11+
return code.replace(/(<span class="(?:d_keyword|kwd)">assert<\/span>(?:<span class="pun">)?\((.*)==(.*)\);)+/g, function(match, text, left, right) {
1212
return "writeln(" + left.trim() + "); "
1313
+ "<span class='d_comment'>// " + right.trim() + "</span>";
1414
});
@@ -90,15 +90,15 @@ $(document).ready(function()
9090
var parent = $(this).parent();
9191
var btnParent = parent.parent().children(".d_example_buttons");
9292
var outputDiv = parent.parent().children(".d_code_output");
93-
setupTextarea(this, {
94-
parent: btnParent,
95-
outputDiv: outputDiv,
96-
stdin: false,
97-
args: false,
98-
transformOutput: wrapIntoMain,
99-
defaultOutput: "All tests passed",
100-
keepCode: true,
101-
outputHeight: "auto"
102-
});
93+
var editor = setupTextarea(this, {
94+
parent: btnParent,
95+
outputDiv: outputDiv,
96+
stdin: false,
97+
args: false,
98+
transformOutput: wrapIntoMain,
99+
defaultOutput: "All tests passed",
100+
keepCode: true,
101+
outputHeight: "auto"
102+
});
103103
});
104104
});

0 commit comments

Comments
 (0)