Skip to content

Commit

Permalink
PHP syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
unconed committed May 16, 2011
1 parent cb6b983 commit 0a91caa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions HTML/outputview/outputfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ widgets.code = function (properties) {
var brushes = {
'application/javascript': 'js',
'application/json': 'js',
'text/javascript': 'js',
'application/x-php': 'php',
};
this.brush = brushes[properties.language];

Expand Down
5 changes: 5 additions & 0 deletions Node/shell/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ exports.plugins.text = function (headers, out) {
exports.plugins.text.prototype = extend(new exports.plugin(), {

begin: function () {
this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
this.out.add(null, view.text('output'));
},

Expand All @@ -146,6 +147,7 @@ exports.plugins.code = function (headers, out) {
exports.plugins.code.prototype = extend(new exports.plugins.text(), {

begin: function () {
this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
this.out.add(null, view.code('output', '', this.headers.get('Content-Type')));

// Buffered output.
Expand All @@ -167,6 +169,8 @@ exports.plugins.code.supports = function (headers) {
var supported = {
'application/json': true,
'application/javascript': true,
'application/x-php': true,
'text/javascript': true,
};
return !!supported[type] * 2;
}
Expand Down Expand Up @@ -296,6 +300,7 @@ exports.plugins.binary = function (headers, out) {
exports.plugins.binary.prototype = extend(new exports.plugin(), {

begin: function () {
this.out.add(null, view.code('output', this.headers.generate(), 'text/plain'));
this.out.add(null, view.code('output', '', 'text/plain'));
},

Expand Down
9 changes: 7 additions & 2 deletions Node/shell/meta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var mime = require('mime');

mime.define({
'application/x-php': ['php'],
});

function isObject(x) {
return typeof x == 'object';
}
Expand Down Expand Up @@ -406,8 +410,9 @@ exports.sniff = function (file, data) {
var parts = file.split('.'),
extension = parts.pop();

if (mime.types[extension]) {
return mime.types[extension];
if ((type = mime.lookup(file)) && (type != 'application/octet-stream')){
process.stderr.write('sniff ' + type + "\n");
return type;
}

if (/[^\u0001-\uFFFF]/('' + data)) {
Expand Down
3 changes: 1 addition & 2 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Tasks:
[:] code syntax highlighter
[ ] cat/echo Piping + progress bar
[ ] command decoration
[ ] interactive execution
Expand Down Expand Up @@ -113,7 +112,7 @@ Prototype:

5) Command Suite
[X] JSON grep
[:] code syntax highlighter
[X] code syntax highlighter
[ ] make a script for git (arguments, file/dir, ...)
[ ] basic top/w infographs + live update
[ ] robust unix basics
Expand Down

0 comments on commit 0a91caa

Please sign in to comment.