Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Commit

Permalink
Adding markdown parsing and github syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Erick Ruiz de Chavez committed May 23, 2013
1 parent 94f49bc commit 5dd8179
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 3 deletions.
20 changes: 19 additions & 1 deletion mdwiki.js
Expand Up @@ -9,8 +9,24 @@ var express = require('express'),
partials = require('express-partials'),
http = require('http'),
path = require('path'),
marked = require('marked'),
highlight = require("highlight.js"),
bunyan = require('bunyan');

// Set default options
marked.setOptions({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
langPrefix: 'language-',
highlight: function (code, lang) {
return lang ? highlight.highlight(lang, code).value : code;
}
});

var app = express(),
log = app.log = bunyan.createLogger({
name: 'mdwiki'
Expand All @@ -29,7 +45,9 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(_path));

app.get('/', function (req, res) {
res.render('index.hjs');
res.render('index.hjs', {
test: marked('```javascript\nfunction test() {\n i.am.using.markdown();\n}\n```')
});
});

http.createServer(app).listen(app.get('port'), function () {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -9,6 +9,8 @@
"hjs": "~0.0.4",
"express-partials": "~0.1.1",
"bunyan": "~0.21.3",
"commander": "~1.1.1"
"commander": "~1.1.1",
"marked": "~0.2.8",
"highlight.js": "~7.3.0"
}
}
127 changes: 127 additions & 0 deletions public/css/github.css
@@ -0,0 +1,127 @@
/*
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/

pre code {
display: block; padding: 0.5em;
color: #333;
background: #f8f8ff
}

pre .comment,
pre .template_comment,
pre .diff .header,
pre .javadoc {
color: #998;
font-style: italic
}

pre .keyword,
pre .css .rule .keyword,
pre .winutils,
pre .javascript .title,
pre .nginx .title,
pre .subst,
pre .request,
pre .status {
color: #333;
font-weight: bold
}

pre .number,
pre .hexcolor,
pre .ruby .constant {
color: #099;
}

pre .string,
pre .tag .value,
pre .phpdoc,
pre .tex .formula {
color: #d14
}

pre .title,
pre .id {
color: #900;
font-weight: bold
}

pre .javascript .title,
pre .lisp .title,
pre .clojure .title,
pre .subst {
font-weight: normal
}

pre .class .title,
pre .haskell .type,
pre .vhdl .literal,
pre .tex .command {
color: #458;
font-weight: bold
}

pre .tag,
pre .tag .title,
pre .rules .property,
pre .django .tag .keyword {
color: #000080;
font-weight: normal
}

pre .attribute,
pre .variable,
pre .lisp .body {
color: #008080
}

pre .regexp {
color: #009926
}

pre .class {
color: #458;
font-weight: bold
}

pre .symbol,
pre .ruby .symbol .string,
pre .lisp .keyword,
pre .tex .special,
pre .prompt {
color: #990073
}

pre .built_in,
pre .lisp .title,
pre .clojure .built_in {
color: #0086b3
}

pre .preprocessor,
pre .pi,
pre .doctype,
pre .shebang,
pre .cdata {
color: #999;
font-weight: bold
}

pre .deletion {
background: #fdd
}

pre .addition {
background: #dfd
}

pre .diff .change {
background: #0086b3
}

pre .chunk {
color: #aaa
}
2 changes: 1 addition & 1 deletion views/index.hjs
Expand Up @@ -3,6 +3,6 @@
sidebar
</div>
<div class="span9">
content
{{{ test }}}
</div>
</div>
1 change: 1 addition & 0 deletions views/layout.hjs
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/github.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
</head>

Expand Down

0 comments on commit 5dd8179

Please sign in to comment.