Skip to content

Commit 11ce6b0

Browse files
committed
Update dist
1 parent 4a3c745 commit 11ce6b0

33 files changed

+92
-538
lines changed

dist/base/jquery.syntax.core.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
pre code.syntax-theme-base {
2+
display: block; }
3+
pre code.syntax-theme-base > span {
4+
display: block;
5+
white-space: pre-wrap; }
6+
pre code.syntax-theme-base .indent {
7+
display: block;
8+
float: left; }
9+
pre code.syntax-theme-base .text {
10+
white-space: pre-wrap;
11+
display: block;
12+
overflow: hidden;
13+
padding-left: 1rem;
14+
text-indent: -1rem; }
15+
116
.syntax-theme-base {
217
font-family: Menlo, Monaco, Consolas, monospace;
318
line-height: 1.15em; }

dist/base/jquery.syntax.layout.fixed.css

Lines changed: 0 additions & 19 deletions
This file was deleted.

dist/base/jquery.syntax.layout.list.css

Lines changed: 0 additions & 37 deletions
This file was deleted.

dist/base/jquery.syntax.layout.plain.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

dist/base/jquery.syntax.layout.table.css

Lines changed: 0 additions & 23 deletions
This file was deleted.

dist/bright/theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Syntax.themes["bright"] = ["grey", "base"]
1+
Syntax.themes["bright"] = ["base"]

dist/grey/jquery.syntax.layout.editor.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/grey/jquery.syntax.layout.fixed.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

dist/grey/jquery.syntax.layout.inline.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/grey/jquery.syntax.layout.list.css

Lines changed: 0 additions & 19 deletions
This file was deleted.

dist/grey/jquery.syntax.layout.plain.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/grey/jquery.syntax.layout.table.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/grey/theme.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/jquery.syntax.cache.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,9 @@ Syntax.styles["jquery.syntax.brush.python"] = ["base/jquery.syntax.brush.python.
5656
Syntax.styles["jquery.syntax.brush.ruby"] = ["base/jquery.syntax.brush.ruby.css"];
5757
Syntax.styles["jquery.syntax.brush.xml"] = ["base/jquery.syntax.brush.xml.css"];
5858
Syntax.styles["jquery.syntax.core"] = ["base/jquery.syntax.core.css", "bright/jquery.syntax.core.css", "paper/jquery.syntax.core.css"];
59-
Syntax.styles["jquery.syntax.layout.editor"] = ["base/jquery.syntax.layout.editor.css", "grey/jquery.syntax.layout.editor.css", "modern/jquery.syntax.layout.editor.css"];
60-
Syntax.styles["jquery.syntax.layout.fixed"] = ["base/jquery.syntax.layout.fixed.css", "grey/jquery.syntax.layout.fixed.css", "modern/jquery.syntax.layout.fixed.css", "paper/jquery.syntax.layout.fixed.css"];
61-
Syntax.styles["jquery.syntax.layout.list"] = ["base/jquery.syntax.layout.list.css", "grey/jquery.syntax.layout.list.css"];
62-
Syntax.styles["jquery.syntax.layout.plain"] = ["base/jquery.syntax.layout.plain.css", "grey/jquery.syntax.layout.plain.css", "modern/jquery.syntax.layout.plain.css"];
63-
Syntax.styles["jquery.syntax.layout.table"] = ["base/jquery.syntax.layout.table.css", "grey/jquery.syntax.layout.table.css"];
64-
Syntax.styles["jquery.syntax.layout.inline"] = ["grey/jquery.syntax.layout.inline.css", "modern/jquery.syntax.layout.inline.css", "paper/jquery.syntax.layout.inline.css"];
59+
Syntax.styles["jquery.syntax.editor"] = ["base/jquery.syntax.editor.css"];
6560

6661
// Theme Configuration
6762
Syntax.themes["base"] = []
68-
Syntax.themes["bright"] = ["grey", "base"]
69-
Syntax.themes["grey"] = ["base"]
70-
Syntax.themes["modern"] = ["base"]
63+
Syntax.themes["bright"] = ["base"]
7164
Syntax.themes["paper"] = ["base"]

dist/jquery.syntax.core.js

Lines changed: 52 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -79,73 +79,6 @@ Syntax.extractElementMatches = function (elems, offset) {
7979
return matches;
8080
}
8181

82-
// Basic layout doesn't do anything e.g. identity layout.
83-
Syntax.layouts.preformatted = function (options, html, container) {
84-
return html;
85-
};
86-
87-
88-
// This function converts from a compressed set of offsets of the form:
89-
// [
90-
// [offset, width, totalOffset],
91-
// ...
92-
// ]
93-
// This means that at a $offset, a tab (single character) was expanded to $width
94-
// single space characters.
95-
// This function produces a lookup table of offsets, where a given character offset
96-
// is mapped to how far the character has been offset.
97-
Syntax.convertToLinearOffsets = function (offsets, length) {
98-
var current = 0, changes = [];
99-
100-
// Anything with offset after offset[current][0] but smaller than offset[current+1][0]
101-
// has been shifted right by offset[current][2]
102-
for (var i = 0; i < length; i++) {
103-
if (offsets[current] && i > offsets[current][0]) {
104-
// Is there a next offset?
105-
if (offsets[current+1]) {
106-
// Is the index less than the start of the next offset?
107-
if (i <= offsets[current+1][0]) {
108-
changes.push(offsets[current][2]);
109-
} else {
110-
// If so, move to the next offset.
111-
current += 1;
112-
i -= 1;
113-
}
114-
} else {
115-
// If there is no next offset we assume this one to the end.
116-
changes.push(offsets[current][2]);
117-
}
118-
} else {
119-
changes.push(changes[changes.length-1] || 0);
120-
}
121-
}
122-
123-
return changes;
124-
}
125-
126-
// Used for tab expansion process, by shifting matches when tab charaters were converted to
127-
// spaces.
128-
Syntax.updateMatchesWithOffsets = function (matches, linearOffsets, text) {
129-
(function (matches) {
130-
for (var i = 0; i < matches.length; i++) {
131-
var match = matches[i];
132-
133-
// Calculate the new start and end points
134-
var offset = match.offset + linearOffsets[match.offset];
135-
var end = match.offset + match.length;
136-
end += linearOffsets[end];
137-
138-
// Start, Length, Text
139-
match.adjust(linearOffsets[match.offset], end - offset, text);
140-
141-
if (match.children.length > 0)
142-
arguments.callee(match.children);
143-
}
144-
})(matches);
145-
146-
return matches;
147-
};
148-
14982
// A helper function which automatically matches expressions with capture groups from the regular expression match.
15083
// Each argument position corresponds to the same index regular expression group.
15184
// Or, override by providing rule.index
@@ -314,6 +247,11 @@ Syntax.Match.prototype.reduce = function (append, process) {
314247
container.className += this.expression.klass;
315248
}
316249

250+
if (this.className) {
251+
container.className += ' ';
252+
container.className += this.className;
253+
}
254+
317255
for (var i = 0; i < this.children.length; i += 1) {
318256
var child = this.children[i], end = child.offset;
319257

@@ -773,6 +711,31 @@ Syntax.Match.prototype.split = function(pattern) {
773711
});
774712
};
775713

714+
Syntax.Match.prototype.splitLines = function() {
715+
var lines = this.split(/\n/g);
716+
717+
for (var i = 0; i < lines.length; i += 1) {
718+
var line = lines[i];
719+
var indentOffset = line.value.search(/\S/);
720+
721+
var top = new Syntax.Match(line.offset, line.length, line.expression, line.value);
722+
723+
if (indentOffset > 0) {
724+
var parts = line.bisectAtOffsets([line.offset + indentOffset]);
725+
top.children = parts;
726+
parts[0].expression = {klass: 'indent'};
727+
parts[1].expression = {klass: 'text'};
728+
} else {
729+
line.expression = {klass: 'text'};
730+
top.children = [line];
731+
}
732+
733+
lines[i] = top;
734+
}
735+
736+
return lines;
737+
}
738+
776739
Syntax.Brush = function () {
777740
// The primary class of this brush. Must be unique.
778741
this.klass = null;
@@ -795,7 +758,7 @@ Syntax.Brush.prototype.derives = function (name) {
795758
return Syntax.brushes[name].getMatches(text);
796759
}
797760
});
798-
}
761+
};
799762

800763
// Return an array of all classes that the brush consists of.
801764
// A derivied brush is its own klass + the klass of any and all parents.
@@ -1003,7 +966,7 @@ Syntax.Brush.prototype.buildTree = function(text, offset, additionalMatches) {
1003966
Syntax.Brush.prototype.process = function(text, matches, options) {
1004967
var top = this.buildTree(text, 0, matches);
1005968

1006-
var lines = top.split(/\n/g);
969+
var lines = top.splitLines();
1007970

1008971
var html = document.createElement('code');
1009972
html.className = 'syntax';
@@ -1102,37 +1065,31 @@ Syntax.highlight = function (elements, options, callback) {
11021065
}
11031066

11041067
Syntax.highlightText(text, brush, matches, options, function(html, brush/*, text, options*/) {
1105-
Syntax.layouts.get(options.layout, function(layout) {
1106-
if (layout) {
1107-
html = layout(options, jQuery(html), container);
1108-
} else {
1109-
html = jQuery(html);
1110-
}
1111-
1112-
// If there is a theme specified, ensure it is added to the top level class.
1113-
if (options.theme) {
1114-
// Load dependencies
1115-
var themes = Syntax.themes[options.theme];
1116-
for (var i = 0; i < themes.length; i += 1) {
1117-
html.addClass("syntax-theme-" + themes[i]);
1118-
}
1068+
html = jQuery(html);
11191069

1120-
// Add the base theme
1121-
html.addClass("syntax-theme-" + options.theme);
1070+
// If there is a theme specified, ensure it is added to the top level class.
1071+
if (options.theme) {
1072+
// Load dependencies
1073+
var themes = Syntax.themes[options.theme];
1074+
for (var i = 0; i < themes.length; i += 1) {
1075+
html.addClass("syntax-theme-" + themes[i]);
11221076
}
11231077

1124-
if (brush.postprocess) {
1125-
html = brush.postprocess(options, html, container);
1126-
}
1078+
// Add the base theme
1079+
html.addClass("syntax-theme-" + options.theme);
1080+
}
11271081

1128-
if (callback) {
1129-
html = callback(options, html, container);
1130-
}
1082+
if (brush.postprocess) {
1083+
html = brush.postprocess(options, html, container);
1084+
}
11311085

1132-
if (html && options.replace === true) {
1133-
container.replaceWith(html);
1134-
}
1135-
});
1086+
if (callback) {
1087+
html = callback(options, html, container);
1088+
}
1089+
1090+
if (html && options.replace === true) {
1091+
container.replaceWith(html);
1092+
}
11361093
});
11371094
});
11381095
};
File renamed without changes.

dist/jquery.syntax.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ var Syntax = {
129129
Syntax.getResource('jquery.syntax.brush', name, callback);
130130
}),
131131

132-
layouts: new ResourceLoader(function (name, callback) {
133-
Syntax.getResource('jquery.syntax.layout', name, callback);
134-
}),
135-
136132
loader: new ResourceLoader(function (name, callback) {
137133
Syntax.getResource('jquery.syntax', name, callback);
138134
}),

0 commit comments

Comments
 (0)