diff --git a/CHANGELOG.md b/CHANGELOG.md index 26bda56b..f58e3862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * updates `modulejs` to 0.4.5 * updates `Moment.js` to 2.8.1 * replaces `underscore` with [`Lo-Dash`](https://github.com/lodash/lodash) 2.4.1 +* replaces `SyntaxHighlighter` with [`Prism`](http://prismjs.com) 2014-08-04 ## v0.25.2 - *2014-07-01* diff --git a/README.md b/README.md index 3df7382e..e7c946a2 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ THE SOFTWARE. [Modernizr](http://www.modernizr.com) (MIT/BSD), [modulejs](http://larsjung.de/modulejs/) (MIT), [Moment.js](http://momentjs.com) (MIT), -[SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) (MIT/GPL) +[Prism](http://prismjs.com) (MIT) [web]: http://larsjung.de/h5ai/ diff --git a/src/_h5ai/client/css/inc/preview-txt.less b/src/_h5ai/client/css/inc/preview-txt.less index 68bff18e..fc384ade 100644 --- a/src/_h5ai/client/css/inc/preview-txt.less +++ b/src/_h5ai/client/css/inc/preview-txt.less @@ -10,81 +10,12 @@ box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.3); &.highlighted { - word-break: break-all; + // word-break: break-all; - tr:hover { - background-color: rgba(0,0,0,0.05); - - .nr { - color: #333; - } - } - - td { - vertical-align: top; + code { font-family: @font-family-mono; font-size: 16px; line-height: 1.2em; - color: #999; - word-break: normal; - - &.nr { - text-align: right; - padding: 0 8px 0 4px; - } - - &.line { - width: 100%; - padding: 0 4px 0 8px; - } - - code { - font-family: @font-family-mono; - font-size: 16px; - line-height: 1.2em; - } - } - - .plain { - color: #000; - } - .comments { - color: #008200; - } - .string { - color: #1111ff; - } - .keyword { - color: #006699; - font-weight: bold; - } - .preprocessor { - color: #999; - } - .variable { - color: #aa7700; - } - .value { - color: #009900; - } - .functions { - color: #ff1493; - } - .constants { - color: #0066cc; - } - .script { - color: #006699; - font-weight: bold; - } - .color1 { - color: #999; - } - .color2 { - color: #ff1493; - } - .color3 { - color: #ff1111; } a, a:active, a:visited { @@ -96,6 +27,126 @@ color: #68A9FF; } } + + .token.comment, + .token.prolog, + .token.doctype, + .token.cdata { + color: #aaa; + } + + .token.punctuation { + color: #999; + } + + .namespace { + opacity: .7; + } + + .token.property, + .token.tag, + .token.boolean, + .token.number, + .token.constant, + .token.symbol { + color: #905; + } + + .token.selector, + .token.attr-name, + .token.string, + .token.builtin { + color: #690; + } + + .token.operator, + .token.entity, + .token.url, + .language-css .token.string, + .style .token.string, + .token.variable { + color: #a67f59; + background: hsla(0,0%,100%,.5); + } + + .token.atrule, + .token.attr-value, + .token.keyword { + color: #07a; + } + + .token.function { + color: #DD4A68; + } + + .token.regex, + .token.important { + color: #e90; + } + + .token.important { + font-weight: bold; + } + + .token.entity { + cursor: help; + } + + // pre.line-numbers { + // position: relative; + // padding-left: 3.8em; + // counter-reset: linenumber; + // } + // pre.line-numbers > code { + // position: relative; + // } + // .line-numbers .line-numbers-rows { + // position: absolute; + // pointer-events: none; + // top: 0; + // font-size: 100%; + // left: -3.8em; + // width: 3em; /* works for line-numbers below 1000 lines */ + // letter-spacing: -1px; + // border-right: 1px solid #999; + + // -webkit-user-select: none; + // -moz-user-select: none; + // -ms-user-select: none; + // user-select: none; + + // } + // .line-numbers-rows > span { + // pointer-events: none; + // display: block; + // counter-increment: linenumber; + // } + // .line-numbers-rows > span:before { + // content: counter(linenumber); + // color: #999; + // display: block; + // padding-right: 0.8em; + // text-align: right; + // } + + // .token.tab:not(:empty):before, + // .token.cr:before, + // .token.lf:before { + // color: hsl(24, 20%, 85%); + // } + // .token.tab:not(:empty):before { + // content: '▸'; + // } + // .token.cr:before { + // content: '␍'; + // } + // .token.lf:before { + // // content: '␊'; + // content: '¶'; + // } + // .token a { + // color: inherit; + // } } diff --git a/src/_h5ai/client/js/inc/core/resource.js b/src/_h5ai/client/js/inc/core/resource.js index 68d1b1f5..af9ccebf 100644 --- a/src/_h5ai/client/js/inc/core/resource.js +++ b/src/_h5ai/client/js/inc/core/resource.js @@ -32,37 +32,31 @@ modulejs.define('core/resource', ['_', '$', 'config', 'core/settings'], function } return fallbackHref + 'file.svg'; - }, - - loadScript = function (filename, callback) { - - $.ajax({ - url: scriptsHref + filename, - dataType: 'script' - }).done(function () { - - callback(); - }); - }, - - loadScriptGlob = function (filename, globalId, callback) { - - if (win[globalId]) { - callback(win[globalId]); - } else { - loadScript(filename, function () { callback(win[globalId]); }); - } - }, - - ensureSH = function (callback) { - - loadScriptGlob('syntaxhighlighter.js', 'SyntaxHighlighter', callback); }; + // loadScript = function (filename, callback) { + + // $.ajax({ + // url: scriptsHref + filename, + // dataType: 'script' + // }).done(function () { + + // callback(); + // }); + // }, + + // loadScriptGlob = function (filename, globalId, callback) { + + // if (win[globalId]) { + // callback(win[globalId]); + // } else { + // loadScript(filename, function () { callback(win[globalId]); }); + // } + // }; + return { image: image, - icon: icon, - ensureSH: ensureSH + icon: icon }; }); diff --git a/src/_h5ai/client/js/inc/ext/preview-txt.js b/src/_h5ai/client/js/inc/ext/preview-txt.js index 72193558..06d5df7d 100644 --- a/src/_h5ai/client/js/inc/ext/preview-txt.js +++ b/src/_h5ai/client/js/inc/ext/preview-txt.js @@ -1,12 +1,12 @@ -modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'core/settings', 'core/event', 'core/resource', 'ext/preview'], function (_, $, marked, allsettings, event, resource, preview) { +modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings', 'core/event', 'ext/preview'], function (_, $, marked, prism, allsettings, event, preview) { var settings = _.extend({ enabled: false, types: {} }, allsettings['preview-txt']), - templateText = '
', + templateText = '
',
templateMarkdown = '',
// adapted from SyntaxHighlighter
@@ -94,38 +94,31 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'core/settings', 'core/e
$('#pv-content').fadeOut(100, function () {
- var $text;
+ var type = settings.types[currentItem.type],
+ $text, $code;
- if (settings.types[currentItem.type] === 'none') {
+ if (type === 'none') {
$text = $(templateMarkdown).text(textContent);
- } else if (settings.types[currentItem.type] === 'fixed') {
+ } else if (type === 'fixed') {
$text = $(templateText).text(textContent);
- } else if (settings.types[currentItem.type] === 'markdown') {
+ } else if (type === 'markdown') {
$text = $(templateMarkdown).html(marked(textContent));
} else {
- $text = $(templateText).text(textContent);
+ $text = $(templateText);
+ $code = $text.find('code');
- resource.ensureSH(function (sh) {
-
- if (sh) {
- var $table = $('