Skip to content

Added support for highlight.js #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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
everpcpc (LDAP support) https://github.com/everpcpc
Gustavo Vargas (hightlight.js) https://github.com/xgvargas
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions lib/renderer.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -26,17 +26,17 @@ mdRenderer.code = function (code, lang, escaped) {
}

if (!lang) {
return '<code class="md-code">' +
return '<pre class="hljs"><code class="md-code">' +
(escaped ? code : escape(code, true)) +
'\n</code>'
'\n</code></pre>'
}

return '<code class="md-code ' +
return '<pre class="hljs"><code class="md-code ' +
this.options.langPrefix +
escape(lang, true) +
'">' +
(escaped ? code : escape(code, true)) +
'\n</code>\n'
'\n</code></pre>\n'
}

Marked.setOptions({
Expand All @@ -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
}
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
"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",
"markdown-toc": "^0.11.7",
"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",
Expand Down
70 changes: 70 additions & 0 deletions public/css/magula.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Description: Magula style for highligh.js
Author: Ruslan Keba <[email protected]>
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;
}
6 changes: 3 additions & 3 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down