From b41feefa0749c832cdcc3f93381bf090a570e1b0 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sun, 21 Apr 2019 18:33:20 -0400 Subject: [PATCH] add /* html */ to get tpl highlighted by plugin https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates --- _server/editor_blockly.js | 21 +++++++++++++-------- _server/editor_table.js | 16 ++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 02453bab..44b03be5 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -2,7 +2,11 @@ editor_blockly = function () { var editor_blockly = {}; - initscript = String.raw` +/////////////////initscript start///////////////////////////// +// do not use String.raw because of highlighting +// Comment tagged templates +// https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates + initscript = /* js */` (function(){ var getCategory = function(name,custom){ for(var node of document.getElementById('toolbox').children) { @@ -30,7 +34,7 @@ editor_blockly = function () { "textInList": "1F金币商店", "use": "money", "need": "20+10*times*(times+1)", - "text": "勇敢的武士啊,给我\${need}金币就可以:", + "text": "勇敢的武士啊,给我\\\${need}金币就可以:", "choices": [ {"text": "生命+800", "effect": "status:hp+=800"}, {"text": "攻击+4", "effect": "status:atk+=4"}, @@ -188,27 +192,27 @@ editor_blockly = function () { '', MotaActionFunctions.actionParser.parseList({"type": "if", "condition": "!core.musicStatus.bgmStatus", "true": [ - "\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳" + "\\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳" ], "false": [] }), '', MotaActionFunctions.actionParser.parse([ - {"type": "choices", "text": "\t[老人,man]少年,你需要钥匙吗?\n我这里有大把的!", + {"type": "choices", "text": "\\t[老人,man]少年,你需要钥匙吗?\\n我这里有大把的!", "choices": [ - {"text": "黄钥匙(\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [ + {"text": "黄钥匙(\\\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [ {"type": "if", "condition": "status:money>=9+flag:shop_times", "true": [ {"type": "addValue", "name": "status:money", "value": "-(9+flag:shop_times)"}, {"type": "addValue", "name": "item:yellowKey", "value": "1"}, ], "false": [ - "\t[老人,man]你的金钱不足!", + "\\t[老人,man]你的金钱不足!", {"type": "revisit"} ] } ]}, - {"text": "蓝钥匙(\${18+2*flag:shop_times}金币)", "color": [0,0,255,1], "action": [ + {"text": "蓝钥匙(\\\${18+2*flag:shop_times}金币)", "color": [0,0,255,1], "action": [ ]}, {"text": "离开", "action": [ {"type": "exit"} @@ -361,7 +365,7 @@ function omitedcheckUpdateFunction(event) { } } try { - var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\i/g, '\\\\i'); + var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\i/g, '\\\\\\\\i'); codeAreaHL.setValue(code); } catch (error) { codeAreaHL.setValue(String(error)); @@ -433,6 +437,7 @@ function omitedcheckUpdateFunction(event) { } })(); `; +/////////////////initscript end ///////////////////////////// var input_ = ''; editor_blockly.runOne = function () { diff --git a/_server/editor_table.js b/_server/editor_table.js index a3b742cd..e141e5ff 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -12,31 +12,31 @@ editor_table_wrapper = function (editor) { values.map(function (v) { return editor.table.option(v) }).join('') - return `\n` + return /* html */`\n` } editor_table.prototype.option = function (value) { - return `\n` + return /* html */`\n` } editor_table.prototype.text = function (value) { - return `\n` + return /* html */`\n` } editor_table.prototype.checkbox = function (value) { - return `\n` + return /* html */`\n` } editor_table.prototype.textarea = function (value, indent) { - return `\n` + return /* html */`\n` } editor_table.prototype.title = function () { - return `\n条目注释值\n` + return /* html */`\n条目注释值\n` } editor_table.prototype.gap = function (field) { - return `--------${field}\n` + return /* html */`--------${field}\n` } editor_table.prototype.tr = function (guid, field, shortField, commentHTMLescape, cobjstr, shortCommentHTMLescape, tdstr) { - return ` + return /* html */` ${shortField} ${shortCommentHTMLescape}
${tdstr}