1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 02:27:19 +00:00

Fix problem with JS parser crashing on skinny tiddlers

This commit is contained in:
Jeremy Ruston 2012-11-18 14:56:33 +00:00
parent 605a7a4124
commit addef09d1c

View File

@ -22,6 +22,13 @@ var JavaScriptParser = function(options) {
// Parse a string of JavaScript code and return the parse tree as a wikitext parse tree // Parse a string of JavaScript code and return the parse tree as a wikitext parse tree
JavaScriptParser.prototype.parse = function(type,code) { JavaScriptParser.prototype.parse = function(type,code) {
// Try to parse the code // Try to parse the code
if(!code) {
return new $tw.Renderer([
$tw.Tree.Element("pre",{"class": "javascript-source"},[
$tw.Tree.Text("")
])
],new $tw.Dependencies(),this.wiki);
}
var parseTree; var parseTree;
try { try {
parseTree = esprima.parse(code,{comment: true,tokens: true,range: true}); parseTree = esprima.parse(code,{comment: true,tokens: true,range: true});