diff --git a/3x5.js b/3x5.js index 940da9a..0b1c382 100644 --- a/3x5.js +++ b/3x5.js @@ -25,7 +25,11 @@ */ function renderCard(state, code) { const script = Notcl.parse(code); - state.output = JSON.stringify(script, null, 2); + if (script[0]) { + state.output = JSON.stringify(script[1], null, 2); + } else { + state.output = script[1]; + } return state.output; } diff --git a/notcl.js b/notcl.js index fc43a8f..7c1b17a 100644 --- a/notcl.js +++ b/notcl.js @@ -64,8 +64,8 @@ var Notcl = (() => { * Parse out a Notcl script into an easier-to-interpret representation. * No script is actually executed yet. * - * @param {string} code - * @returns Script + * @param {string} code to parse + * @returns {[true, Notcl.Script] | [false, string]} parsed list of commands, or error message on failure */ parse(code) { /* Preprocess */ @@ -85,9 +85,9 @@ var Notcl = (() => { ); return [ false, - `Error at position ${commands[1]} -${before}${after} -${"-".repeat(before.length)}^`, + `
Error at position ${commands[1]} +${escapeHtml(before + "" + after)} +${"-".repeat(before.length)}^`, ]; } },