Expand extension map and catch highlight errors
This commit is contained in:
parent
12aa622c2d
commit
6285d665ad
1
TODO.md
1
TODO.md
@ -1,7 +1,6 @@
|
|||||||
# TODO
|
# TODO
|
||||||
* tests
|
* tests
|
||||||
* fix that chrome bug where it loads the doc twice
|
* fix that chrome bug where it loads the doc twice
|
||||||
* expand extension map
|
|
||||||
* kick expiration back by increment on each view
|
* kick expiration back by increment on each view
|
||||||
* Add file extensions ourselves to push state
|
* Add file extensions ourselves to push state
|
||||||
* Proper markdown highlighting
|
* Proper markdown highlighting
|
||||||
|
@ -14,11 +14,15 @@ haste_document.prototype.load = function(key, callback, lang) {
|
|||||||
_this.locked = true;
|
_this.locked = true;
|
||||||
_this.key = key;
|
_this.key = key;
|
||||||
_this.data = res.data;
|
_this.data = res.data;
|
||||||
|
try {
|
||||||
var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data);
|
var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data);
|
||||||
|
} catch(err) {
|
||||||
|
high = hljs.highlightAuto(res.data);
|
||||||
|
}
|
||||||
callback({
|
callback({
|
||||||
value: high.value,
|
value: high.value,
|
||||||
key: key,
|
key: key,
|
||||||
language: lang || high.language
|
language: high.language || lang
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function(err) {
|
error: function(err) {
|
||||||
@ -116,8 +120,11 @@ haste.prototype.newDocument = function(hideHistory) {
|
|||||||
|
|
||||||
// Map of common extensions
|
// Map of common extensions
|
||||||
haste.extensionMap = {
|
haste.extensionMap = {
|
||||||
'rb': 'ruby',
|
rb: 'ruby', py: 'python', pl: 'perl', php: 'php', scala: 'scala', go: 'go',
|
||||||
'py': 'python'
|
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
|
// Map an extension to a language
|
||||||
|
Loading…
Reference in New Issue
Block a user