Commit 6285d665 authored by John Crepezzi's avatar John Crepezzi
Browse files

Expand extension map and catch highlight errors

parent 12aa622c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
# 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
+11 −4
Original line number Diff line number Diff line
@@ -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