Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

PHP syntax highlighting

  • Loading branch information...
commit 0a91caa32a44a7e67a2507be73eed106fa36be36 1 parent cb6b983
unconed authored May 16, 2011
2  HTML/outputview/outputfactory.js
@@ -309,6 +309,8 @@ widgets.code = function (properties) {
309 309
   var brushes = {
310 310
     'application/javascript': 'js',
311 311
     'application/json': 'js',
  312
+    'text/javascript': 'js',
  313
+    'application/x-php': 'php',
312 314
   };
313 315
   this.brush = brushes[properties.language];
314 316
   
5  Node/shell/formatter.js
@@ -121,6 +121,7 @@ exports.plugins.text = function (headers, out) {
121 121
 exports.plugins.text.prototype = extend(new exports.plugin(), {
122 122
 
123 123
   begin: function () {
  124
+    this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
124 125
     this.out.add(null, view.text('output'));
125 126
   },
126 127
 
@@ -146,6 +147,7 @@ exports.plugins.code = function (headers, out) {
146 147
 exports.plugins.code.prototype = extend(new exports.plugins.text(), {
147 148
 
148 149
   begin: function () {
  150
+    this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
149 151
     this.out.add(null, view.code('output', '', this.headers.get('Content-Type')));
150 152
 
151 153
     // Buffered output.
@@ -167,6 +169,8 @@ exports.plugins.code.supports = function (headers) {
167 169
   var supported = {
168 170
     'application/json': true,
169 171
     'application/javascript': true,
  172
+    'application/x-php': true,
  173
+    'text/javascript': true,
170 174
   };
171 175
   return !!supported[type] * 2;
172 176
 }
@@ -296,6 +300,7 @@ exports.plugins.binary = function (headers, out) {
296 300
 exports.plugins.binary.prototype = extend(new exports.plugin(), {
297 301
 
298 302
   begin: function () {
  303
+    this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
299 304
     this.out.add(null, view.code('output', '', 'text/plain'));
300 305
   },
301 306
 
9  Node/shell/meta.js
... ...
@@ -1,5 +1,9 @@
1 1
 var mime = require('mime');
2 2
 
  3
+mime.define({
  4
+  'application/x-php': ['php'],
  5
+});
  6
+
3 7
 function isObject(x) {
4 8
   return typeof x == 'object';
5 9
 }
@@ -406,8 +410,9 @@ exports.sniff = function (file, data) {
406 410
   var parts = file.split('.'),
407 411
       extension = parts.pop();
408 412
 
409  
-  if (mime.types[extension]) {
410  
-    return mime.types[extension];
  413
+  if ((type = mime.lookup(file)) && (type != 'application/octet-stream')){
  414
+    process.stderr.write('sniff ' + type + "\n");
  415
+    return type;
411 416
   }
412 417
 
413 418
   if (/[^\u0001-\uFFFF]/('' + data)) {
3  todo.txt
... ...
@@ -1,5 +1,4 @@
1 1
 Tasks:
2  
-[:] code syntax highlighter
3 2
 [ ] cat/echo Piping + progress bar
4 3
 [ ] command decoration
5 4
 [ ] interactive execution
@@ -113,7 +112,7 @@ Prototype:
113 112
 
114 113
 5) Command Suite
115 114
 [X] JSON grep
116  
-[:] code syntax highlighter
  115
+[X] code syntax highlighter
117 116
 [ ] make a script for git (arguments, file/dir, ...)
118 117
 [ ] basic top/w infographs + live update
119 118
 [ ] robust unix basics

0 notes on commit 0a91caa

Please sign in to comment.
Something went wrong with that request. Please try again.