Skip to content

Commit

Permalink
Extracted marked.js to modify it slightly, fixed syntax highlighting,…
Browse files Browse the repository at this point in the history
… changed syntax highlighting theme.
  • Loading branch information
jeromegn committed Jul 28, 2012
1 parent efa27b6 commit 2c4bee7
Show file tree
Hide file tree
Showing 9 changed files with 857 additions and 154 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -47,7 +47,7 @@ All the configuration parameters detailed [options](#options) are also valid.

Pipe the response HTML into a file and open it. Example using `curl`:

```shell
```bash
curl -X POST --data-urlencode content@README.md \
http://documentup.com/compiled > index.html && open index.html
```
Expand Down Expand Up @@ -138,7 +138,7 @@ h1's (# in markdown) will appear as first level navigation in the sidebar while

Example:

```plain
```markdown
# Project name / Title (won't appear in the sidebar)

Some intro text if you want.
Expand Down
133 changes: 0 additions & 133 deletions app/stylesheets/github.styl

This file was deleted.

4 changes: 2 additions & 2 deletions app/stylesheets/screen.styl
Expand Up @@ -2,7 +2,7 @@

@import "normalize";

@import "github";
@import "syntax/tomorrow";

html {
height: 100%;
Expand Down Expand Up @@ -183,7 +183,7 @@ a {
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
line-height: 1.5;
}
code { background: #f8f8ff; padding: 1px 2px; border: 1px solid #ddd; }
code { background: #f7f8f1; padding: 1px 2px; border: 1px solid #CCCCCC; }
pre code {padding: 10px 12px; word-wrap: normal; }
tt { display: block; margin: 1.625em 0; }
hr { margin-bottom:1.625em; }
Expand Down
43 changes: 43 additions & 0 deletions app/stylesheets/syntax/tomorrow.styl
@@ -0,0 +1,43 @@
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
.tomorrow-comment, pre .comment, pre .title {
color: #8e908c;
}

.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo {
color: #c82829;
}

.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant {
color: #f5871f;
}

.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute {
color: #eab700;
}

.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata {
color: #718c00;
}

.tomorrow-aqua, pre .css .hexcolor {
color: #3e999f;
}

.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title {
color: #4271ae;
}

.tomorrow-purple, pre .keyword, pre .javascript .function {
color: #8959a8;
}

pre code {
display: block;
background: white;
color: #4d4d4c;
font-family: Menlo, Monaco, Consolas, monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px;
}
2 changes: 1 addition & 1 deletion app/stylesheets/themes/v1.styl
Expand Up @@ -2,7 +2,7 @@

@import "../normalize";

@import "../github";
@import "../syntax/tomorrow";

html {
height: 100%;
Expand Down
5 changes: 0 additions & 5 deletions lib/highlighter.js

This file was deleted.

25 changes: 16 additions & 9 deletions lib/markdown.coffee
@@ -1,5 +1,18 @@
marked = require("marked")
hljs = require("./highlighter")
marked = require("./marked.js")
hljs = require("highlight.js")

console.log Object.keys(hljs.LANGUAGES)

marked.setOptions
gfm: true
highlight: (code, lang)->
if lang in Object.keys(hljs.LANGUAGES)
return hljs.highlight(lang, code).value
else if lang != "plain" && lang != "text"
return hljs.highlightAuto(code).value
else
return code



Markdown =
Expand All @@ -12,19 +25,13 @@ Markdown =
tokens = marked.lexer(markdown)
token = undefined
for token in tokens
if token.type is "heading"
if token.type == "heading"
to_param = token.text.parameterize()
if token.depth == 2
current_h2 = to_param
token.depth = "#{token.depth} id='#{to_param}'"
else if token.depth == 3
token.depth = "#{token.depth} id='#{current_h2}/#{to_param}'"
else if token.type is "code"
if token.lang in Object.keys(hljs.LANGUAGES)
token.text = hljs.highlight(token.lang, token.text).value
else
token.text = hljs.highlightAuto(token.text).value
token.escaped = true;

return marked.parser(tokens)

Expand Down

0 comments on commit 2c4bee7

Please sign in to comment.