diff --git a/AUTHORS b/AUTHORS index df8aae90..81a60b09 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,4 +12,5 @@ David McFadzean (static assets management) https://github.com/macterra Bradly Sharpe https://github.com/brad7928 Collin Reynolds https://github.com/creynold jon r https://github.com/almereyda -everpcpc (LDAP support) https://github.com/everpcpc \ No newline at end of file +everpcpc (LDAP support) https://github.com/everpcpc +Gustavo Vargas (hightlight.js) https://github.com/xgvargas diff --git a/README.md b/README.md index 728560d9..cc13d928 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Features - Pages can be embedded into another site - Authentication via Google, Github, LDAP and local name/password -For code syntax highlighting, Jingo uses the `node-syntaxhighlighter` module. For the list of supported languages, please refer to [this page](https://github.com/thlorenz/node-syntaxhighlighter/tree/master/lib/scripts). +For code syntax highlighting, Jingo uses the `highlight.js` module. For the list of supported languages, please refer to [this page](https://highlightjs.org/static/demo/). ![Screenshot](https://dl.dropboxusercontent.com/u/152161/jingo/ss3.png) diff --git a/lib/renderer.js b/lib/renderer.js index faaf75d6..907919b3 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -1,10 +1,10 @@ var Marked = require('marked') var cryptoz = require('crypto') -var Nsh = require('node-syntaxhighlighter') var namer = require('./namer') var Page = require('./models').Page var directives = require('./directives') var Configurable = require('./configurable') +var hljs = require('highlight.js') var Configuration = function () { Configurable.call(this) @@ -26,17 +26,17 @@ mdRenderer.code = function (code, lang, escaped) { } if (!lang) { - return '' + + return '
' +
            (escaped ? code : escape(code, true)) +
-           '\n'
+           '\n
' } - return '' + (escaped ? code : escape(code, true)) + - '\n\n' + '\n\n' } Marked.setOptions({ @@ -49,7 +49,7 @@ Marked.setOptions({ sanitize: false, // To be able to add iframes highlight: function (code, lang) { lang = lang || 'text' - return Nsh.highlight(code, Nsh.getLanguage(lang) || Nsh.getLanguage('text'), {gutter: lang !== 'text'}) + return hljs.highlight(lang, code).value } }) diff --git a/package.json b/package.json index c032f4d1..0573540a 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "express-session": "^1.9.3", "express-validator": "^2.7.0", "gravatar": "^1.1.0", + "highlight.js": "^9.10.0", "jade": "*", "js-yaml": "^3.1.0", "lodash": "^2.4.1", @@ -54,7 +55,6 @@ "marked": "^0.3.5", "method-override": "^2.3.0", "morgan": "^1.5.0", - "node-syntaxhighlighter": "*", "passport": "^0.2.0", "passport-github": "^0.1.5", "passport-google-oauth": "^0.1.5", diff --git a/public/css/magula.css b/public/css/magula.css new file mode 100644 index 00000000..44dee5e8 --- /dev/null +++ b/public/css/magula.css @@ -0,0 +1,70 @@ +/* +Description: Magula style for highligh.js +Author: Ruslan Keba +Website: http://rukeba.com/ +Version: 1.0 +Date: 2009-01-03 +Music: Aphex Twin / Xtal +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background-color: #f4f4f4; +} + +.hljs, +.hljs-subst { + color: black; +} + +.hljs-string, +.hljs-title, +.hljs-symbol, +.hljs-bullet, +.hljs-attribute, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #050; +} + +.hljs-comment, +.hljs-quote { + color: #777; +} + +.hljs-number, +.hljs-regexp, +.hljs-literal, +.hljs-type, +.hljs-link { + color: #800; +} + +.hljs-deletion, +.hljs-meta { + color: #00e; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-built_in, +.hljs-tag, +.hljs-name { + font-weight: bold; + color: navy; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/public/css/style.css b/public/css/style.css index 105fdf95..eff5018d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -305,11 +305,11 @@ code { code.md-code { background-color: transparent; - white-space: nowrap; + /*white-space: nowrap;*/ padding: 0; display: block; - margin-bottom: 20px; - box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); + /*margin-bottom: 20px;*/ + /*box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);*/ border-width: 0; } diff --git a/views/layout.jade b/views/layout.jade index 503c3dbb..77467ba2 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -13,6 +13,7 @@ include mixins/links +asset("/css/style.css") +asset("/css/ionicons.min.css") +asset("/css/shCoreDefault.css") + +asset("/css/magula.css") block styles if hasCustomStyle() style.