Skip to content

Commit e91166c

Browse files
committed
Added a CSS post processing function for options.showColors, which adds a small box next to any CSS color showing the desired color.
Fixed a minor rule.allow for colors. Added weblinks to clang code.
1 parent 7367ad3 commit e91166c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

jquery.syntax.brush.clang.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Syntax.register('clang', function(brush) {
2020
brush.push(access, {klass: 'access'});
2121

2222
// Objective-C classes
23-
brush.push({pattern: /\b[A-Z][\w]*\b/g, klass: 'type'});
23+
brush.push({pattern: /\b[A-Z_][\w]*\b/g, klass: 'type'});
2424

2525
brush.push({
2626
pattern: /#.*$/gmi,
@@ -30,6 +30,7 @@ Syntax.register('clang', function(brush) {
3030

3131
brush.push(Syntax.lib.cStyleComment);
3232
brush.push(Syntax.lib.cppStyleComment);
33+
brush.push(Syntax.lib.webLink);
3334

3435
// Objective-C style functions
3536
brush.push({pattern: /\w+:(?=.*(\]|;|\{))/g, klass: 'function'});

jquery.syntax.brush.css.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Syntax.register('css', function(brush) {
3636

3737
brush.push({
3838
pattern: /\:(.*?(?=\})|(.|\n)*?(?=(\}|\;)))/g,
39-
matches: Syntax.extractMatches({klass: 'value', only: ['properties']})
39+
matches: Syntax.extractMatches({klass: 'value', allow: ['color'], only: ['properties']})
4040
});
4141

4242
brush.push({pattern: /[\-\w]+:/g, klass: 'property'});
@@ -47,5 +47,17 @@ Syntax.register('css', function(brush) {
4747
brush.push(Syntax.lib.stringEscape);
4848

4949
brush.push(Syntax.lib.cStyleFunction);
50+
51+
brush.postprocess = function(options, html, container) {
52+
if (options.showColors === true) {
53+
$('.color', html).each(function() {
54+
var text = $(this).text();
55+
var colorBox = $('<span style="font-size: 0.5em; margin: 4px; border: 1px solid black">&nbsp;&nbsp;</span>').css('background-color', text);
56+
$(this).append(colorBox);
57+
});
58+
}
59+
60+
return html;
61+
};
5062
});
5163

0 commit comments

Comments
 (0)