Skip to content

Instantly share code, notes, and snippets.

@fczuardi
Created April 13, 2010 20:49
Show Gist options
  • Save fczuardi/365065 to your computer and use it in GitHub Desktop.
Save fczuardi/365065 to your computer and use it in GitHub Desktop.
Wiki Creole syntax highlight for Bespin
syntaxInfoForLineFragment: function(context, state, line, start, end) {
var promise = new Promise();
var attrs = [];
var stickySupported = this._stickySupported;
line = line + '\n'
var lineLength = line.length;
var states = this.get('states');
"define metadata";
({
"description": "Wiki Creole syntax highlighter",
"dependencies": {
"syntax_manager": "0.0"
},
"provides": [
{
"ep": "fileextension",
"name": "creole",
"syntax": "creole"
},
{
"ep": "syntax",
"name": "creole",
"pointer": "#CreoleSyntax"
}
]
});
"end";
var SC = require('sproutcore/runtime').SC;
var Promise = require('bespin:promise').Promise;
var StandardSyntax = require('syntax_manager:controllers/standardsyntax').
StandardSyntax;
exports.CreoleSyntax = StandardSyntax.create({
states: {
start: [
{
regex: /^\{\{\{/
,tag: 'directive'
,then: 'nowiki'
}
,{
regex: /^\~(http|ftp)\:\/\/[^\s\n]+/
,tag: 'plain'
}
,{
regex: /^\~[^\s\n]/
,tag: 'plain'
}
,{
regex: /^\={1,5}\s/
,tag: 'string'
,then: 'heading'
}
,{
regex: /^----\n/
,tag: 'error'
}
,{
regex: /^\\\\/
,tag: 'error'
}
,{
regex: /^\*\*[^\s\*]/
,tag: 'directive'
,then: 'bold'
}
,{
regex: /^\*{1,5}\s/
,tag: 'comment'
}
,{
regex: /^\#{1,5}\s/
,tag: 'comment'
}
,{
regex: /^(http|ftp)\:\/\/[^\s\n]+/
,tag: 'keyword'
}
,{
regex: /^\/\//
,tag: 'directive'
,then: 'italic'
}
,{
regex: /^\[\[/
,tag: 'keyword'
,then: 'link'
}
,{
regex: /^\{\{/
,tag: 'operator'
,then: 'image'
}
,{
regex: /^[^\=]+.*\={1,5}\s/
,tag: 'plain'
}
,{
regex: /^./
,tag: 'plain'
}
]
,nowiki: [
{
regex: /^\}\}\}/
,tag: 'directive'
,then: 'start'
}
,{
regex: /^./
,tag: 'directive'
}
]
,heading: [
{
regex: /^\n/
,tag: 'string'
,then: 'start'
}
,{
regex: /^./
,tag: 'string'
}
]
,link: [
{
regex: /^\]\]/
,tag: 'keyword'
,then: 'start'
}
,{
regex: /^./
,tag: 'keyword'
}
]
,image: [
{
regex: /^\}\}/
,tag: 'operator'
,then: 'start'
}
,{
regex: /^./
,tag: 'operator'
}
]
,bold: [
{
regex: /^\*\*/
,tag: 'directive'
,then: 'start'
}
,{
regex: /^\n/
,tag: 'directive'
,then: 'boldbreak1'
}
,{
regex: /^./
,tag: 'directive'
}
]
,boldbreak1: [
{
regex: /^\*\*/
,tag: 'directive'
,then: 'start'
}
,{
regex: /^\n/
,tag: 'directive'
,then: 'start'
}
,{
regex: /^./
,tag: 'directive'
}
]
,italic: [
{
regex: /^(http\:\/\/.|ftp\:\/\/.)/
,tag: 'directive'
}
,{
regex: /^\/\//
,tag: 'directive'
,then: 'start'
}
,{
regex: /^\n/
,tag: 'directive'
,then: 'italicbreak1'
}
,{
regex: /^./
,tag: 'directive'
}
]
,italicbreak1: [
{
regex: /^\/\//
,tag: 'directive'
,then: 'start'
}
,{
regex: /^\n/
,tag: 'directive'
,then: 'start'
}
,{
regex: /^./
,tag: 'directive'
}
]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment