mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-23 17:50:19 +01:00
Expand extension map and catch highlight errors
This commit is contained in:
parent
12aa622c2d
commit
6285d665ad
2 changed files with 11 additions and 5 deletions
1
TODO.md
1
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
|
||||
|
|
|
@ -14,11 +14,15 @@ haste_document.prototype.load = function(key, callback, lang) {
|
|||
_this.locked = true;
|
||||
_this.key = key;
|
||||
_this.data = 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
|
||||
|
|
Loading…
Reference in a new issue