Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Created May 4, 2011 20:19
Show Gist options
  • Save johnbintz/955949 to your computer and use it in GitHub Desktop.
Save johnbintz/955949 to your computer and use it in GitHub Desktop.
Super-basic SCSS formatting for SHJS
# language definition for scss style sheets
include "c_comment.lang"
string = '#[a-f0-9]{3,6}'
keyword = '[\#\.]+(?=\{)'
selector = '[#\.][[:word:]]+'
keyword = '\$([^ :;]+)'
preproc = '@[[:word:]]+'
function = '([[:word:]]|[_-])+(?=\()'
state paren delim "(" ")" begin
value = '[[:word:]]+'
end
property = '[[:word:]-]+[[:blank:]]*(?=:)'
string = '#([[:word:]]+)'
cbracket = "{|}"
include "symbols.lang"
if (! this.sh_languages) {
this.sh_languages = {};
}
sh_languages['scss'] = [
[
[
/\/\/\//g,
'sh_comment',
1
],
[
/\/\//g,
'sh_comment',
7
],
[
/\/\*\*/g,
'sh_comment',
8
],
[
/\/\*/g,
'sh_comment',
9
],
[
/#[a-f0-9]{3,6}/g,
'sh_string',
-1
],
[
/[\#\.]+(?=\{)/g,
'sh_keyword',
-1
],
[
/[#\.][A-Za-z0-9_]+/g,
'sh_selector',
-1
],
[
/\$(?:[^ :;]+)/g,
'sh_keyword',
-1
],
[
/@[A-Za-z0-9_]+/g,
'sh_preproc',
-1
],
[
/(?:[A-Za-z0-9_]|[_-])+(?=\()/g,
'sh_function',
-1
],
[
/\(/g,
'sh_paren',
10,
1
],
[
/[A-Za-z0-9_-]+[ \t]*(?=:)/g,
'sh_property',
-1
],
[
/#(?:[A-Za-z0-9_]+)/g,
'sh_string',
-1
],
[
/\{|\}/g,
'sh_cbracket',
-1
],
[
/~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g,
'sh_symbol',
-1
]
],
[
[
/$/g,
null,
-2
],
[
/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,
'sh_url',
-1
],
[
/<\?xml/g,
'sh_preproc',
2,
1
],
[
/<!DOCTYPE/g,
'sh_preproc',
4,
1
],
[
/<!--/g,
'sh_comment',
5
],
[
/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)(?:\/)?>/g,
'sh_keyword',
-1
],
[
/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,
'sh_keyword',
6,
1
],
[
/&(?:[A-Za-z0-9]+);/g,
'sh_preproc',
-1
],
[
/<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g,
'sh_keyword',
-1
],
[
/<(?:\/)?[A-Za-z][A-Za-z0-9]*/g,
'sh_keyword',
6,
1
],
[
/@[A-Za-z]+/g,
'sh_type',
-1
],
[
/(?:TODO|FIXME|BUG)(?:[:]?)/g,
'sh_todo',
-1
]
],
[
[
/\?>/g,
'sh_preproc',
-2
],
[
/([^=" \t>]+)([ \t]*)(=?)/g,
['sh_type', 'sh_normal', 'sh_symbol'],
-1
],
[
/"/g,
'sh_string',
3
]
],
[
[
/\\(?:\\|")/g,
null,
-1
],
[
/"/g,
'sh_string',
-2
]
],
[
[
/>/g,
'sh_preproc',
-2
],
[
/([^=" \t>]+)([ \t]*)(=?)/g,
['sh_type', 'sh_normal', 'sh_symbol'],
-1
],
[
/"/g,
'sh_string',
3
]
],
[
[
/-->/g,
'sh_comment',
-2
],
[
/<!--/g,
'sh_comment',
5
]
],
[
[
/(?:\/)?>/g,
'sh_keyword',
-2
],
[
/([^=" \t>]+)([ \t]*)(=?)/g,
['sh_type', 'sh_normal', 'sh_symbol'],
-1
],
[
/"/g,
'sh_string',
3
]
],
[
[
/$/g,
null,
-2
]
],
[
[
/\*\//g,
'sh_comment',
-2
],
[
/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,
'sh_url',
-1
],
[
/<\?xml/g,
'sh_preproc',
2,
1
],
[
/<!DOCTYPE/g,
'sh_preproc',
4,
1
],
[
/<!--/g,
'sh_comment',
5
],
[
/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)(?:\/)?>/g,
'sh_keyword',
-1
],
[
/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,
'sh_keyword',
6,
1
],
[
/&(?:[A-Za-z0-9]+);/g,
'sh_preproc',
-1
],
[
/<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g,
'sh_keyword',
-1
],
[
/<(?:\/)?[A-Za-z][A-Za-z0-9]*/g,
'sh_keyword',
6,
1
],
[
/@[A-Za-z]+/g,
'sh_type',
-1
],
[
/(?:TODO|FIXME|BUG)(?:[:]?)/g,
'sh_todo',
-1
]
],
[
[
/\*\//g,
'sh_comment',
-2
],
[
/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,
'sh_url',
-1
],
[
/(?:TODO|FIXME|BUG)(?:[:]?)/g,
'sh_todo',
-1
]
],
[
[
/\)/g,
'sh_paren',
-2
],
[
/[A-Za-z0-9_]+/g,
'sh_value',
-1
]
]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment