From 6285d665ad4e6e380a8656f531617b7cfc4c6c37 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Wed, 23 Nov 2011 16:55:26 -0500 Subject: [PATCH] Expand extension map and catch highlight errors --- TODO.md | 1 - static/application.js | 15 +++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 563f1c5..ad4ae8f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO * tests * fix that chrome bug where it loads the doc twice -* expand extension map * kick expiration back by increment on each view * Add file extensions ourselves to push state * Proper markdown highlighting diff --git a/static/application.js b/static/application.js index 5687ca7..2f4f86d 100644 --- a/static/application.js +++ b/static/application.js @@ -14,11 +14,15 @@ haste_document.prototype.load = function(key, callback, lang) { _this.locked = true; _this.key = key; _this.data = res.data; - var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data); + try { + var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data); + } catch(err) { + high = hljs.highlightAuto(res.data); + } callback({ value: high.value, key: key, - language: lang || high.language + language: high.language || lang }); }, error: function(err) { @@ -116,8 +120,11 @@ haste.prototype.newDocument = function(hideHistory) { // Map of common extensions haste.extensionMap = { - 'rb': 'ruby', - 'py': 'python' + rb: 'ruby', py: 'python', pl: 'perl', php: 'php', scala: 'scala', go: 'go', + xml: 'xml', html: 'xml', htm: 'xml', css: 'css', js: 'javascript', vbs: 'vbscript', + lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec', + vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini', + diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell' }; // Map an extension to a language