Commit bf079c24 authored by Stefan Tatschner's avatar Stefan Tatschner

Replace highlight.js with rouge-fork rugments

I decided to create a fork of rouge as rouge lacks a HTML formatter with
the required options such as wrapping a line with <span> tags.
Furthermore I was not really convinced about the clarity of rouge's
source code.

Rugments 1.0.0beta3 for now only includes some basic linting and a new
HTML formatter. Everything else should behave the same.
parent 377ae460
...@@ -265,3 +265,4 @@ end ...@@ -265,3 +265,4 @@ end
gem "newrelic_rpm" gem "newrelic_rpm"
gem 'octokit', '3.7.0' gem 'octokit', '3.7.0'
gem "rugments"
...@@ -468,6 +468,7 @@ GEM ...@@ -468,6 +468,7 @@ GEM
rubyntlm (0.4.0) rubyntlm (0.4.0)
rubypants (0.2.0) rubypants (0.2.0)
rugged (0.21.2) rugged (0.21.2)
rugments (1.0.0.beta3)
safe_yaml (0.9.7) safe_yaml (0.9.7)
sanitize (2.1.0) sanitize (2.1.0)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
...@@ -706,6 +707,7 @@ DEPENDENCIES ...@@ -706,6 +707,7 @@ DEPENDENCIES
redis-rails redis-rails
request_store request_store
rspec-rails rspec-rails
rugments
sanitize (~> 2.0) sanitize (~> 2.0)
sass-rails (~> 4.0.2) sass-rails (~> 4.0.2)
sdoc sdoc
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#= require g.bar-min #= require g.bar-min
#= require chart-lib.min #= require chart-lib.min
#= require branch-graph #= require branch-graph
#= require highlight.pack
#= require ace/ace #= require ace/ace
#= require ace/ext-searchbox #= require ace/ext-searchbox
#= require d3 #= require d3
......
...@@ -4,7 +4,6 @@ $ -> ...@@ -4,7 +4,6 @@ $ ->
class Dispatcher class Dispatcher
constructor: () -> constructor: () ->
@initSearch() @initSearch()
@initHighlight()
@initPageScripts() @initPageScripts()
initPageScripts: -> initPageScripts: ->
...@@ -130,10 +129,3 @@ class Dispatcher ...@@ -130,10 +129,3 @@ class Dispatcher
project_ref = opts.data('autocomplete-project-ref') project_ref = opts.data('autocomplete-project-ref')
new SearchAutocomplete(path, project_id, project_ref) new SearchAutocomplete(path, project_id, project_ref)
initHighlight: ->
$('.highlight pre code').each (i, e) ->
$(e).html($.map($(e).html().split("\n"), (line, i) ->
"<span class='line' id='LC" + (i + 1) + "'>" + line + "</span>"
).join("\n"))
hljs.highlightBlock(e)
...@@ -114,10 +114,6 @@ class @Notes ...@@ -114,10 +114,6 @@ class @Notes
if @isNewNote(note) if @isNewNote(note)
@note_ids.push(note.id) @note_ids.push(note.id)
$('ul.main-notes-list').append(note.html) $('ul.main-notes-list').append(note.html)
code = "#note_" + note.id + " .highlight pre code"
$(code).each (i, e) ->
hljs.highlightBlock(e)
### ###
Check if note does not exists on page Check if note does not exists on page
...@@ -265,9 +261,6 @@ class @Notes ...@@ -265,9 +261,6 @@ class @Notes
note_li.replaceWith(note.html) note_li.replaceWith(note.html)
note_li.find('.note-edit-form').hide() note_li.find('.note-edit-form').hide()
note_li.find('.note-text').show() note_li.find('.note-text').show()
code = "#note_" + note.id + " .highlight pre code"
$(code).each (i, e) ->
hljs.highlightBlock(e)
### ###
Called in response to clicking the edit note link Called in response to clicking the edit note link
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*= require jquery.ui.autocomplete *= require jquery.ui.autocomplete
*= require jquery.atwho *= require jquery.atwho
*= require select2 *= require select2
*= require highlightjs.min
*= require_self *= require_self
*= require dropzone/basic *= require dropzone/basic
*/ */
......
.highlighted-data { .file-content.code {
border: none; border: none;
box-shadow: none; box-shadow: none;
margin: 0px; margin: 0px;
...@@ -13,8 +13,13 @@ ...@@ -13,8 +13,13 @@
font-size: 12px !important; font-size: 12px !important;
line-height: 16px !important; line-height: 16px !important;
margin: 0; margin: 0;
overflow: auto;
overflow-y: hidden;
white-space: pre;
word-wrap: normal;
code { code {
font-family: $monospace_font;
white-space: pre; white-space: pre;
word-wrap: normal; word-wrap: normal;
padding: 0; padding: 0;
...@@ -25,10 +30,6 @@ ...@@ -25,10 +30,6 @@
} }
} }
.hljs {
padding: 0;
}
.line-numbers { .line-numbers {
padding: 10px; padding: 10px;
text-align: right; text-align: right;
...@@ -51,18 +52,18 @@ ...@@ -51,18 +52,18 @@
} }
} }
} }
}
.highlight { .note-text .code {
overflow: auto; border: none;
overflow-y: hidden; box-shadow: none;
background: $box_bg;
pre { padding: 1em;
white-space: pre;
word-wrap: normal;
code { code {
font-family: $monospace_font; font-family: $monospace_font;
} white-space: pre;
} word-wrap: normal;
padding: 0;
} }
} }
.dark { /* https://github.com/MozMorris/tomorrow-pygments */
background-color: #232323; .code.dark {
.line.hll {
background: #558;
}
.highlight{
border-left: 1px solid #444;
}
.no-highlight {
color: #DDD;
}
pre.code,
.line-numbers,
.line-numbers a { .line-numbers a {
color: #666; background-color: #1d1f21 !important;
} color: #c5c8c6 !important;
}
pre {
background-color: #232323; pre.code {
} border-left: 1px solid #666;
}
.hljs {
display: block; pre.hll {
background: #232323; background-color: #fff !important;
color: #E6E1DC; }
}
.hll { background-color: #373b41 }
.hljs-comment, .c { color: #969896 } /* Comment */
.hljs-template_comment, .err { color: #cc6666 } /* Error */
.hljs-javadoc, .k { color: #b294bb } /* Keyword */
.hljs-shebang { .l { color: #de935f } /* Literal */
color: #BC9458; .n { color: #c5c8c6 } /* Name */
font-style: italic; .o { color: #8abeb7 } /* Operator */
} .p { color: #c5c8c6 } /* Punctuation */
.cm { color: #969896 } /* Comment.Multiline */
.hljs-keyword, .cp { color: #969896 } /* Comment.Preproc */
.ruby .hljs-function .hljs-keyword, .c1 { color: #969896 } /* Comment.Single */
.hljs-request, .cs { color: #969896 } /* Comment.Special */
.hljs-status, .gd { color: #cc6666 } /* Generic.Deleted */
.nginx .hljs-title, .ge { font-style: italic } /* Generic.Emph */
.method, .gh { color: #c5c8c6; font-weight: bold } /* Generic.Heading */
.hljs-list .hljs-title { .gi { color: #b5bd68 } /* Generic.Inserted */
color: #C26230; .gp { color: #969896; font-weight: bold } /* Generic.Prompt */
} .gs { font-weight: bold } /* Generic.Strong */
.gu { color: #8abeb7; font-weight: bold } /* Generic.Subheading */
.hljs-string, .kc { color: #b294bb } /* Keyword.Constant */
.hljs-number, .kd { color: #b294bb } /* Keyword.Declaration */
.hljs-regexp, .kn { color: #8abeb7 } /* Keyword.Namespace */
.hljs-tag .hljs-value, .kp { color: #b294bb } /* Keyword.Pseudo */
.hljs-cdata, .kr { color: #b294bb } /* Keyword.Reserved */
.hljs-filter .hljs-argument, .kt { color: #f0c674 } /* Keyword.Type */
.hljs-attr_selector, .ld { color: #b5bd68 } /* Literal.Date */
.apache .hljs-cbracket, .m { color: #de935f } /* Literal.Number */
.hljs-date, .s { color: #b5bd68 } /* Literal.String */
.tex .hljs-command, .na { color: #81a2be } /* Name.Attribute */
.markdown .hljs-link_label { .nb { color: #c5c8c6 } /* Name.Builtin */
color: #A5C261; .nc { color: #f0c674 } /* Name.Class */
} .no { color: #cc6666 } /* Name.Constant */
.nd { color: #8abeb7 } /* Name.Decorator */
.hljs-subst { .ni { color: #c5c8c6 } /* Name.Entity */
color: #519F50; .ne { color: #cc6666 } /* Name.Exception */
} .nf { color: #81a2be } /* Name.Function */
.nl { color: #c5c8c6 } /* Name.Label */
.hljs-tag, .nn { color: #f0c674 } /* Name.Namespace */
.hljs-tag .hljs-keyword, .nx { color: #81a2be } /* Name.Other */
.hljs-tag .hljs-title, .py { color: #c5c8c6 } /* Name.Property */
.hljs-doctype, .nt { color: #8abeb7 } /* Name.Tag */
.hljs-sub .hljs-identifier, .nv { color: #cc6666 } /* Name.Variable */
.hljs-pi, .ow { color: #8abeb7 } /* Operator.Word */
.input_number { .w { color: #c5c8c6 } /* Text.Whitespace */
color: #E8BF6A; .mf { color: #de935f } /* Literal.Number.Float */
} .mh { color: #de935f } /* Literal.Number.Hex */
.mi { color: #de935f } /* Literal.Number.Integer */
.hljs-identifier { .mo { color: #de935f } /* Literal.Number.Oct */
color: #D0D0FF; .sb { color: #b5bd68 } /* Literal.String.Backtick */
} .sc { color: #c5c8c6 } /* Literal.String.Char */
.sd { color: #969896 } /* Literal.String.Doc */
.hljs-class .hljs-title, .s2 { color: #b5bd68 } /* Literal.String.Double */
.haskell .hljs-type, .se { color: #de935f } /* Literal.String.Escape */
.smalltalk .hljs-class, .sh { color: #b5bd68 } /* Literal.String.Heredoc */
.hljs-javadoctag, .si { color: #de935f } /* Literal.String.Interpol */
.hljs-yardoctag, .sx { color: #b5bd68 } /* Literal.String.Other */
.hljs-phpdoc { .sr { color: #b5bd68 } /* Literal.String.Regex */
text-decoration: none; .s1 { color: #b5bd68 } /* Literal.String.Single */
} .ss { color: #b5bd68 } /* Literal.String.Symbol */
.bp { color: #c5c8c6 } /* Name.Builtin.Pseudo */
.hljs-constant { .vc { color: #cc6666 } /* Name.Variable.Class */
color: #DA4939; .vg { color: #cc6666 } /* Name.Variable.Global */
} .vi { color: #cc6666 } /* Name.Variable.Instance */
.il { color: #de935f } /* Literal.Number.Integer.Long */
.hljs-symbol,
.hljs-built_in,
.ruby .hljs-symbol .hljs-string,
.ruby .hljs-symbol .hljs-identifier,
.markdown .hljs-link_url,
.hljs-attribute {
color: #6D9CBE;
}
.markdown .hljs-link_url {
text-decoration: underline;
}
.hljs-params,
.hljs-variable,
.clojure .hljs-attribute {
color: #D0D0FF;
}
.css .hljs-tag,
.hljs-rules .hljs-property,
.hljs-pseudo,
.tex .hljs-special {
color: #CDA869;
}
.css .hljs-class {
color: #9B703F;
}
.hljs-rules .hljs-keyword {
color: #C5AF75;
}
.hljs-rules .hljs-value {
color: #CF6A4C;
}
.css .hljs-id {
color: #8B98AB;
}
.hljs-annotation,
.apache .hljs-sqbracket,
.nginx .hljs-built_in {
color: #9B859D;
}
.hljs-preprocessor,
.hljs-preprocessor *,
.hljs-pragma {
color: #8996A8 !important;
}
.hljs-hexcolor,
.css .hljs-value .hljs-number {
color: #A5C261;
}
.hljs-title,
.hljs-decorator,
.css .hljs-function {
color: #FFC66D;
}
.diff .hljs-header,
.hljs-chunk {
background-color: #2F33AB;
color: #E6E1DC;
display: inline-block;
width: 100%;
}
.diff .hljs-change {
background-color: #4A410D;
color: #F8F8F8;
display: inline-block;
width: 100%;
}
.hljs-addition {
background-color: #144212;
color: #E6E1DC;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #600;
color: #E6E1DC;
display: inline-block;
width: 100%;
}
.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata {
opacity: 0.7;
}
} }
.monokai { /* https://github.com/richleland/pygments-css/blob/master/monokai.css */
background-color: #272822; .code.monokai {
.highlight{
border-left: 1px solid #444;
}
.line.hll {
background: #558;
}
.no-highlight {
color: #DDD;
}
pre.highlight,
.line-numbers,
.line-numbers a { .line-numbers a {
color: #666; background:#272822 !important;
} color:#f8f8f2 !important;
}
pre {
background-color: #272822; pre.code {
color: #f8f8f2; border-left: 1px solid #555;
} }
.hljs { .hll { background-color: #49483e }
display: block; .c { color: #75715e } /* Comment */
background: #272822; .err { color: #960050; background-color: #1e0010 } /* Error */
} .k { color: #66d9ef } /* Keyword */
.l { color: #ae81ff } /* Literal */
.hljs-tag, .n { color: #f8f8f2 } /* Name */
.hljs-tag .hljs-title, .o { color: #f92672 } /* Operator */
.hljs-strong, .p { color: #f8f8f2 } /* Punctuation */
.hljs-change, .cm { color: #75715e } /* Comment.Multiline */
.hljs-winutils, .cp { color: #75715e } /* Comment.Preproc */
.hljs-flow, .c1 { color: #75715e } /* Comment.Single */
.lisp .hljs-title, .cs { color: #75715e } /* Comment.Special */
.clojure .hljs-built_in, .ge { font-style: italic } /* Generic.Emph */
.hljs-keyword, .gs { font-weight: bold } /* Generic.Strong */
.nginx .hljs-title, .kc { color: #66d9ef } /* Keyword.Constant */
.tex .hljs-special { .kd { color: #66d9ef } /* Keyword.Declaration */
color: #F92672; .kn { color: #f92672 } /* Keyword.Namespace */
} .kp { color: #66d9ef } /* Keyword.Pseudo */
.kr { color: #66d9ef } /* Keyword.Reserved */
.hljs { .kt { color: #66d9ef } /* Keyword.Type */
color: #F8F8F2; .ld { color: #e6db74 } /* Literal.Date */
} .m { color: #ae81ff } /* Literal.Number */
.s { color: #e6db74 } /* Literal.String */
.asciidoc .hljs-code, .na { color: #a6e22e } /* Name.Attribute */
.markdown .hljs-code, .nb { color: #f8f8f2 } /* Name.Builtin */
.hljs-literal, .nc { color: #a6e22e } /* Name.Class */
.hljs-function .hljs-keyword { .no { color: #66d9ef } /* Name.Constant */
color: #66D9EF; .nd { color: #a6e22e } /* Name.Decorator */
} .ni { color: #f8f8f2 } /* Name.Entity */
.ne { color: #a6e22e } /* Name.Exception */
.nf { color: #a6e22e } /* Name.Function */
.hljs-code, .nl { color: #f8f8f2 } /* Name.Label */
.hljs-class .hljs-title, .nn { color: #f8f8f2 } /* Name.Namespace */
.hljs-header { .nx { color: #a6e22e } /* Name.Other */
color: white; .py { color: #f8f8f2 } /* Name.Property */
} .nt { color: #f92672 } /* Name.Tag */
.nv { color: #f8f8f2 } /* Name.Variable */
.hljs-link_label, .ow { color: #f92672 } /* Operator.Word */
.hljs-attribute, .w { color: #f8f8f2 } /* Text.Whitespace */
.hljs-symbol, .mf { color: #ae81ff } /* Literal.Number.Float */
.hljs-symbol .hljs-string, .mh { color: #ae81ff } /* Literal.Number.Hex */
.hljs-value, .mi { color: #ae81ff } /* Literal.Number.Integer */
.hljs-constant, .mo { color: #ae81ff } /* Literal.Number.Oct */
.hljs-number, .sb { color: #e6db74 } /* Literal.String.Backtick */
.hljs-regexp { .sc { color: #e6db74 } /* Literal.String.Char */
color: #AE81FF; .sd { color: #e6db74 } /* Literal.String.Doc */
} .s2 { color: #e6db74 } /* Literal.String.Double */
.se { color: #ae81ff } /* Literal.String.Escape */
.hljs-string { .sh { color: #e6db74 } /* Literal.String.Heredoc */
color: #E6DB74; .si { color: #e6db74 } /* Literal.String.Interpol */
} .sx { color: #e6db74 } /* Literal.String.Other */
.sr { color: #e6db74 } /* Literal.String.Regex */
.hljs-params { .s1 { color: #e6db74 } /* Literal.String.Single */
color: #fd971f; .ss { color: #e6db74 } /* Literal.String.Symbol */
} .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.vc { color: #f8f8f2 } /* Name.Variable.Class */
.hljs-link_url, .vg { color: #f8f8f2 } /* Name.Variable.Global */
.hljs-tag .hljs-value, .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.hljs-bullet, .il { color: #ae81ff } /* Literal.Number.Integer.Long */
.hljs-subst,
.hljs-title, .gh { } /* Generic Heading & Diff Header */
.hljs-emphasis, .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */
.hljs-type, .gd { color: #f92672; } /* Generic.Deleted & Diff Deleted */
.hljs-preprocessor, .gi { color: #a6e22e; } /* Generic.Inserted & Diff Inserted */
.hljs-pragma,
.ruby .hljs-class .hljs-parent,
.hljs-built_in,
.sql .hljs-aggregate,
.django .hljs-template_tag,
.django .hljs-variable,
.smalltalk .hljs-class,
.hljs-javadoc,
.django .hljs-filter .hljs-argument,
.smalltalk .hljs-localvars,
.smalltalk .hljs-array,
.hljs-attr_selector,
.hljs-pseudo,
.hljs-addition,
.hljs-stream,
.hljs-envvar,
.apache .hljs-tag,
.apache .hljs-cbracket,
.tex .hljs-command,
.hljs-prompt {
color: #A6E22E;
}
.hljs-comment,
.hljs-annotation,
.smartquote,
.hljs-blockquote,
.hljs-horizontal_rule,
.hljs-template_comment,
.hljs-decorator,
.hljs-pi,
.hljs-doctype,
.hljs-deletion,
.hljs-shebang,
.apache .hljs-sqbracket,
.tex .hljs-formula {
color: #75715E;
}
.hljs-keyword,
.hljs-literal,
.css .hljs-id,
.hljs-phpdoc,
.hljs-title,
.hljs-header,
.haskell .hljs-type,
.vbscript .hljs-built_in,
.sql .hljs-aggregate,
.rsl .hljs-built_in,
.smalltalk .hljs-class,
.diff .hljs-header,
.hljs-chunk,
.hljs-winutils,
.bash .hljs-variable,
.apache .hljs-tag,
.tex .hljs-special,
.hljs-request,
.hljs-status {
font-weight: bold;
}
.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata {
opacity: 0.5;
}
} }
.solarized-dark { /* https://gist.github.com/qguv/7936275 */
background-color: #002B36; .code.solarized-dark {