and change syntax highlighter API once more
This commit is contained in:
parent
bec9222cf2
commit
7c3a40368f
2 changed files with 9 additions and 14 deletions
|
@ -19,7 +19,7 @@ Ox.load('UI', {
|
|||
.append(
|
||||
Ox.FormElementGroup({
|
||||
elements: [
|
||||
'showLineNumbers', 'showPage', 'showReturns', 'showSpaces', 'showTabs', 'stripComments'
|
||||
'showLineNumbers', 'showPage', 'showLinebreaks', 'showTabs', 'showWhitespace', 'stripComments'
|
||||
].map(function(v, i) {
|
||||
return Ox.Checkbox({
|
||||
overlap: 'right',
|
||||
|
|
|
@ -6,14 +6,14 @@ Ox.SyntaxHighlighter <function> Syntax Highlighter
|
|||
options <o> Options
|
||||
lineLength <n|0> If larger than zero, show edge of page
|
||||
offset <n|1> First line number
|
||||
showLinebreaks <b|false> If true, show linebreaks
|
||||
showLineNumbers <b|false> If true, show line numbers
|
||||
showReturns <b|false> If true, show linebreaks
|
||||
showSpaces <b|false> If true, show whitespace
|
||||
showWhitespace <b|false> If true, show whitespace
|
||||
showTabs <b|false> If true, show tabs
|
||||
source <s|''> JavaScript source
|
||||
stripComments <b|false> If true, strip comments
|
||||
tabSize <n|4> Number of spaces per tab
|
||||
self <o> Shared private
|
||||
self <o> Shared private variable
|
||||
@*/
|
||||
|
||||
Ox.SyntaxHighlighter = function(options, self) {
|
||||
|
@ -23,10 +23,10 @@ Ox.SyntaxHighlighter = function(options, self) {
|
|||
.defaults({
|
||||
lineLength: 0,
|
||||
offset: 1,
|
||||
showLinebreaks: false,
|
||||
showLineNumbers: false,
|
||||
showReturns: false,
|
||||
showSpaces: false,
|
||||
showTabs: false,
|
||||
showWhitespace: false,
|
||||
source: '',
|
||||
stripComments: false,
|
||||
tabSize: 4,
|
||||
|
@ -40,14 +40,14 @@ Ox.SyntaxHighlighter = function(options, self) {
|
|||
var $lineNumbers, $line, $source, width,
|
||||
lines, source = '', tokens,
|
||||
linebreak = (
|
||||
self.options.showReturns ?
|
||||
self.options.showLinebreaks ?
|
||||
'<span class="OxLinebreak">\u21A9</span>' : ''
|
||||
) + '<br/>',
|
||||
tab = (
|
||||
self.options.showTabs ?
|
||||
'<span class="OxTab">\u2192</span>' : ''
|
||||
) + Ox.repeat(' ', self.options.tabSize - self.options.showTabs),
|
||||
whitespace = self.options.showSpaces ? '\u00B7' : ' ';
|
||||
whitespace = self.options.showWhitespace ? '\u00B7' : ' ';
|
||||
self.options.source = self.options.source
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace(/\r/g, '\n');
|
||||
|
@ -59,7 +59,7 @@ Ox.SyntaxHighlighter = function(options, self) {
|
|||
!(self.options.stripComments && token.type == 'comment')
|
||||
) {
|
||||
classNames = 'Ox' + Ox.toTitleCase(token.type);
|
||||
if (self.options.showSpaces && token.type == 'whitespace') {
|
||||
if (self.options.showWhitespace && token.type == 'whitespace') {
|
||||
if (isAfterLinebreak() && hasIrregularSpaces()) {
|
||||
classNames += ' OxLeading'
|
||||
} else if (isBeforeLinebreak()) {
|
||||
|
@ -100,11 +100,6 @@ Ox.SyntaxHighlighter = function(options, self) {
|
|||
}
|
||||
$source = new Ox.Element()
|
||||
.addClass('OxSourceCode')
|
||||
.css({
|
||||
background: '-webkit-linear-gradient(left, rgb(255, 255, 255) ' +
|
||||
width + 'px, rgb(192, 192, 192) ' + width + 'px, rgb(255, 255, 255) ' +
|
||||
(width + 1) + 'px)'
|
||||
})
|
||||
.html(source)
|
||||
.appendTo(that);
|
||||
if (self.options.lineLength) {
|
||||
|
|
Loading…
Reference in a new issue