Commit 892be53f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #8425 from rumpelsepp/rouge

Replace highlight.js with rouge-fork rugments
parents 23255bff 08951620
...@@ -46,7 +46,7 @@ gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' ...@@ -46,7 +46,7 @@ gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
gem 'gitlab_omniauth-ldap', '1.2.0', require: "omniauth-ldap" gem 'gitlab_omniauth-ldap', '1.2.0', require: "omniauth-ldap"
# Git Wiki # Git Wiki
gem 'gollum-lib', '~> 3.0.0' gem 'gollum-lib', '~> 4.0.0'
# Language detection # Language detection
gem "gitlab-linguist", "~> 3.0.0", require: "linguist" gem "gitlab-linguist", "~> 3.0.0", require: "linguist"
...@@ -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"
...@@ -166,13 +166,14 @@ GEM ...@@ -166,13 +166,14 @@ GEM
rugged (~> 0.19) rugged (~> 0.19)
gherkin-ruby (0.3.1) gherkin-ruby (0.3.1)
racc racc
github-markup (1.1.0) github-markup (1.3.1)
posix-spawn (~> 0.3.8)
gitlab-flowdock-git-hook (0.4.2.2) gitlab-flowdock-git-hook (0.4.2.2)
gitlab-grit (>= 2.4.1) gitlab-grit (>= 2.4.1)
multi_json multi_json
gitlab-grack (2.0.0.pre) gitlab-grack (2.0.0.pre)
rack (~> 1.5.1) rack (~> 1.5.1)
gitlab-grit (2.6.12) gitlab-grit (2.7.2)
charlock_holmes (~> 0.6) charlock_holmes (~> 0.6)
diff-lcs (~> 1.1) diff-lcs (~> 1.1)
mime-types (~> 1.15) mime-types (~> 1.15)
...@@ -194,11 +195,13 @@ GEM ...@@ -194,11 +195,13 @@ GEM
omniauth (~> 1.0) omniauth (~> 1.0)
pyu-ruby-sasl (~> 0.0.3.1) pyu-ruby-sasl (~> 0.0.3.1)
rubyntlm (~> 0.3) rubyntlm (~> 0.3)
gollum-lib (3.0.0) gollum-grit_adapter (0.1.0)
github-markup (~> 1.1.0) gitlab-grit (~> 2.7.1)
gitlab-grit (~> 2.6.5) gollum-lib (4.0.0)
nokogiri (~> 1.6.1) github-markup (~> 1.3.1)
rouge (~> 1.3.3) gollum-grit_adapter (~> 0.1.0)
nokogiri (~> 1.6.4)
rouge (~> 1.7.4)
sanitize (~> 2.1.0) sanitize (~> 2.1.0)
stringex (~> 2.5.1) stringex (~> 2.5.1)
gon (5.0.1) gon (5.0.1)
...@@ -296,7 +299,7 @@ GEM ...@@ -296,7 +299,7 @@ GEM
treetop (~> 1.4.8) treetop (~> 1.4.8)
method_source (0.8.2) method_source (0.8.2)
mime-types (1.25.1) mime-types (1.25.1)
mini_portile (0.6.0) mini_portile (0.6.1)
minitest (5.3.5) minitest (5.3.5)
mousetrap-rails (1.4.6) mousetrap-rails (1.4.6)
multi_json (1.10.1) multi_json (1.10.1)
...@@ -308,8 +311,8 @@ GEM ...@@ -308,8 +311,8 @@ GEM
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.8.0) net-ssh (2.8.0)
newrelic_rpm (3.9.4.245) newrelic_rpm (3.9.4.245)
nokogiri (1.6.2.1) nokogiri (1.6.5)
mini_portile (= 0.6.0) mini_portile (~> 0.6.0)
nprogress-rails (0.1.2.3) nprogress-rails (0.1.2.3)
oauth (0.4.7) oauth (0.4.7)
oauth2 (0.8.1) oauth2 (0.8.1)
...@@ -445,7 +448,7 @@ GEM ...@@ -445,7 +448,7 @@ GEM
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
rinku (1.7.3) rinku (1.7.3)
rouge (1.3.3) rouge (1.7.4)
rspec (2.14.1) rspec (2.14.1)
rspec-core (~> 2.14.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0) rspec-expectations (~> 2.14.0)
...@@ -465,6 +468,7 @@ GEM ...@@ -465,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)
...@@ -536,7 +540,7 @@ GEM ...@@ -536,7 +540,7 @@ GEM
sprockets (~> 2.8) sprockets (~> 2.8)
stamp (0.5.0) stamp (0.5.0)
state_machine (1.2.0) state_machine (1.2.0)
stringex (2.5.1) stringex (2.5.2)
temple (0.6.7) temple (0.6.7)
term-ansicolor (1.2.2) term-ansicolor (1.2.2)
tins (~> 0.8) tins (~> 0.8)
...@@ -651,7 +655,7 @@ DEPENDENCIES ...@@ -651,7 +655,7 @@ DEPENDENCIES
gitlab_git (= 7.0.0.rc14) gitlab_git (= 7.0.0.rc14)
gitlab_meta (= 7.0) gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.2.0) gitlab_omniauth-ldap (= 1.2.0)
gollum-lib (~> 3.0.0) gollum-lib (~> 4.0.0)
gon (~> 5.0.0) gon (~> 5.0.0)
grape (~> 0.6.1) grape (~> 0.6.1)
grape-entity (~> 0.4.2) grape-entity (~> 0.4.2)
...@@ -703,6 +707,7 @@ DEPENDENCIES ...@@ -703,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
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,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 {
.highlight{
border-left: 1px solid #113b46;
}
.line.hll {
background: #000;
}
.no-highlight {
color: #DDD;
}
pre {
background-color: #002B36;
color: #eee;
}
pre.code,
.line-numbers,
.line-numbers a { .line-numbers a {
color: #666; background-color: #002b36 !important;
color: #93a1a1 !important;
} }
.hljs { pre.code {
display: block; border-left: 1px solid #113b46;
background: #002b36;
color: #839496;
}
.hljs-comment,
.hljs-template_comment,
.diff .hljs-header,
.hljs-doctype,
.hljs-pi,
.lisp .hljs-string,
.hljs-javadoc {
color: #586e75;
}
/* Solarized Green */
.hljs-keyword,
.hljs-winutils,
.method,
.hljs-addition,
.css .hljs-tag,
.hljs-request,
.hljs-status,
.nginx .hljs-title {
color: #859900;
} }
/* Solarized Cyan */ /* Solarized Dark
.hljs-number,
.hljs-command,
.hljs-string,
.hljs-tag .hljs-value,
.hljs-rules .hljs-value,
.hljs-phpdoc,
.tex .hljs-formula,
.hljs-regexp,
.hljs-hexcolor,
.hljs-link_url {
color: #2aa198;
}
/* Solarized Blue */ For use with Jekyll and Pygments
.hljs-title,
.hljs-localvars,
.hljs-chunk,
.hljs-decorator,
.hljs-built_in,
.hljs-identifier,
.vhdl .hljs-literal,
.hljs-id,
.css .hljs-function {
color: #268bd2;
}
/* Solarized Yellow */ http://ethanschoonover.com/solarized
.hljs-attribute,
.hljs-variable,
.lisp .hljs-body,
.smalltalk .hljs-number,
.hljs-constant,
.hljs-class .hljs-title,
.hljs-parent,
.haskell .hljs-type,
.hljs-link_reference {
color: #b58900;
}
/* Solarized Orange */ SOLARIZED HEX ROLE
.hljs-preprocessor, --------- -------- ------------------------------------------
.hljs-preprocessor .hljs-keyword, base03 #002b36 background
.hljs-pragma, base01 #586e75 comments / secondary content
.hljs-shebang, base1 #93a1a1 body text / default code / primary content
.hljs-symbol, orange #cb4b16 constants
.hljs-symbol .hljs-string, red #dc322f regex, special keywords
.diff .hljs-change, blue #268bd2 reserved keywords
.hljs-special, cyan #2aa198 strings, numbers
.hljs-attr_selector, green #859900 operators, other keywords
.hljs-subst, */
.hljs-cdata,
.clojure .hljs-title,
.css .hljs-pseudo,
.hljs-header {
color: #cb4b16;
}
/* Solarized Red */ .c { color: #586e75 } /* Comment */
.hljs-deletion, .err { color: #93a1a1 } /* Error */
.hljs-important { .g { color: #93a1a1 } /* Generic */
color: #dc322f; .k { color: #859900 } /* Keyword */
} .l { color: #93a1a1 } /* Literal */
.n { color: #93a1a1 } /* Name */
/* Solarized Violet */ .o { color: #859900 } /* Operator */
.hljs-link_label { .x { color: #cb4b16 } /* Other */
color: #6c71c4; .p { color: #93a1a1 } /* Punctuation */
} .cm { color: #586e75 } /* Comment.Multiline */
.cp { color: #859900 } /* Comment.Preproc */
.tex .hljs-formula { .c1 { color: #586e75 } /* Comment.Single */
background: #073642; .cs { color: #859900 } /* Comment.Special */
} .gd { color: #2aa198 } /* Generic.Deleted */
.ge { color: #93a1a1; font-style: italic } /* Generic.Emph */
.gr { color: #dc322f } /* Generic.Error */
.gh { color: #cb4b16 } /* Generic.Heading */
.gi { color: #859900 } /* Generic.Inserted */
.go { color: #93a1a1 } /* Generic.Output */
.gp { color: #93a1a1 } /* Generic.Prompt */
.gs { color: #93a1a1; font-weight: bold } /* Generic.Strong */
.gu { color: #cb4b16 } /* Generic.Subheading */
.gt { color: #93a1a1 } /* Generic.Traceback */
.kc { color: #cb4b16 } /* Keyword.Constant */
.kd { color: #268bd2 } /* Keyword.Declaration */
.kn { color: #859900 } /* Keyword.Namespace */
.kp { color: #859900 } /* Keyword.Pseudo */
.kr { color: #268bd2 } /* Keyword.Reserved */
.kt { color: #dc322f } /* Keyword.Type */
.ld { color: #93a1a1 } /* Literal.Date */
.m { color: #2aa198 } /* Literal.Number */
.s { color: #2aa198 } /* Literal.String */
.na { color: #93a1a1 } /* Name.Attribute */
.nb { color: #B58900 } /* Name.Builtin */
.nc { color: #268bd2 } /* Name.Class */
.no { color: #cb4b16 } /* Name.Constant */
.nd { color: #268bd2 } /* Name.Decorator */
.ni { color: #cb4b16 } /* Name.Entity */
.ne { color: #cb4b16 } /* Name.Exception */
.nf { color: #268bd2 } /* Name.Function */
.nl { color: #93a1a1 } /* Name.Label */
.nn { color: #93a1a1 } /* Name.Namespace */
.nx { color: #93a1a1 } /* Name.Other */
.py { color: #93a1a1 } /* Name.Property */
.nt { color: #268bd2 } /* Name.Tag */
.nv { color: #268bd2 } /* Name.Variable */
.ow { color: #859900 } /* Operator.Word */
.w { color: #93a1a1 } /* Text.Whitespace */
.mf { color: #2aa198 } /* Literal.Number.Float */
.mh { color: #2aa198 } /* Literal.Number.Hex */
.mi { color: #2aa198 } /* Literal.Number.Integer */
.mo { color: #2aa198 } /* Literal.Number.Oct */
.sb { color: #586e75 } /* Literal.String.Backtick */
.sc { color: #2aa198 } /* Literal.String.Char */
.sd { color: #93a1a1 } /* Literal.String.Doc */
.s2 { color: #2aa198 } /* Literal.String.Double */
.se { color: #cb4b16 } /* Literal.String.Escape */
.sh { color: #93a1a1 } /* Literal.String.Heredoc */
.si { color: #2aa198 } /* Literal.String.Interpol */
.sx { color: #2aa198 } /* Literal.String.Other */
.sr { color: #dc322f } /* Literal.String.Regex */
.s1 { color: #2aa198 } /* Literal.String.Single */
.ss { color: #2aa198 } /* Literal.String.Symbol */
.bp { color: #268bd2 } /* Name.Builtin.Pseudo */
.vc { color: #268bd2 } /* Name.Variable.Class */
.vg { color: #268bd2 } /* Name.Variable.Global */
.vi { color: #268bd2 } /* Name.Variable.Instance */
.il { color: #2aa198 } /* Literal.Number.Integer.Long */
} }
/* https://gist.github.com/qguv/7936275 */
.code.solarized-light {
pre.code,
.line-numbers,
.line-numbers a {
background-color: #fdf6e3 !important;
color: #586e75 !important;
}
pre.code {
border-left: 1px solid #c5d0d4;
}
/* Solarized Light
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base01 #586e75 body text / default code / primary content
base1 #93a1a1 comments / secondary content
base3 #fdf6e3 background
orange #cb4b16 constants
red #dc322f regex, special keywords
blue #268bd2 reserved keywords
cyan #2aa198 strings, numbers
green #859900 operators, other keywords
*/
.c { color: #93a1a1 } /* Comment */
.err { color: #586e75 } /* Error */
.g { color: #586e75 } /* Generic */
.k { color: #859900 } /* Keyword */
.l { color: #586e75 } /* Literal */
.n { color: #586e75 } /* Name */
.o { color: #859900 } /* Operator */
.x { color: #cb4b16 } /* Other */
.p { color: #586e75 } /* Punctuation */
.cm { color: #93a1a1 } /* Comment.Multiline */
.cp { color: #859900 } /* Comment.Preproc */
.c1 { color: #93a1a1 } /* Comment.Single */
.cs { color: #859900 } /* Comment.Special */
.gd { color: #2aa198 } /* Generic.Deleted */
.ge { color: #586e75; font-style: italic } /* Generic.Emph */
.gr { color: #dc322f } /* Generic.Error */
.gh { color: #cb4b16 } /* Generic.Heading */
.gi { color: #859900 } /* Generic.Inserted */
.go { color: #586e75 } /* Generic.Output */
.gp { color: #586e75 } /* Generic.Prompt */
.gs { color: #586e75; font-weight: bold } /* Generic.Strong */
.gu { color: #cb4b16 } /* Generic.Subheading */
.gt { color: #586e75 } /* Generic.Traceback */
.kc { color: #cb4b16 } /* Keyword.Constant */
.kd { color: #268bd2 } /* Keyword.Declaration */
.kn { color: #859900 } /* Keyword.Namespace */
.kp { color: #859900 } /* Keyword.Pseudo */
.kr { color: #268bd2 } /* Keyword.Reserved */
.kt { color: #dc322f } /* Keyword.Type */
.ld { color: #586e75 } /* Literal.Date */
.m { color: #2aa198 } /* Literal.Number */
.s { color: #2aa198 } /* Literal.String */
.na { color: #586e75 } /* Name.Attribute */
.nb { color: #B58900 } /* Name.Builtin */
.nc { color: #268bd2 } /* Name.Class */
.no { color: #cb4b16 } /* Name.Constant */
.nd { color: #268bd2 } /* Name.Decorator */
.ni { color: #cb4b16 } /* Name.Entity */
.ne { color: #cb4b16 } /* Name.Exception */
.nf { color: #268bd2 } /* Name.Function */
.nl { color: #586e75 } /* Name.Label */
.nn { color: #586e75 } /* Name.Namespace */
.nx { color: #586e75 } /* Name.Other */
.py { color: #586e75 } /* Name.Property */
.nt { color: #268bd2 } /* Name.Tag */
.nv { color: #268bd2 } /* Name.Variable */
.ow { color: #859900 } /* Operator.Word */
.w { color: #586e75 } /* Text.Whitespace */
.mf { color: #2aa198 } /* Literal.Number.Float */
.mh { color: #2aa198 } /* Literal.Number.Hex */
.mi { color: #2aa198 } /* Literal.Number.Integer */
.mo { color: #2aa198 } /* Literal.Number.Oct */
.sb { color: #93a1a1 } /* Literal.String.Backtick */
.sc { color: #2aa198 } /* Literal.String.Char */
.sd { color: #586e75 } /* Literal.String.Doc */
.s2 { color: #2aa198 } /* Literal.String.Double */
.se { color: #cb4b16 } /* Literal.String.Escape */
.sh { color: #586e75 } /* Literal.String.Heredoc */
.si { color: #2aa198 } /* Literal.String.Interpol */
.sx { color: #2aa198 } /* Literal.String.Other */
.sr { color: #dc322f } /* Literal.String.Regex */
.s1 { color: #2aa198 } /* Literal.String.Single */
.ss { color: #2aa198 } /* Literal.String.Symbol */
.bp { color: #268bd2 } /* Name.Builtin.Pseudo */
.vc { color: #268bd2 } /* Name.Variable.Class */
.vg { color: #268bd2 } /* Name.Variable.Global */
.vi { color: #268bd2 } /* Name.Variable.Instance */
.il { color: #2aa198 } /* Literal.Number.Integer.Long */
}
.white { /* https://github.com/aahan/pygments-github-style */
.line.hll { .code.white {
background: #FFA;
}
pre {
background-color: #fff;
color: #333;
}
.hljs {
background: #FFF;
}
pre.highlight,
.line-numbers,
.line-numbers a { .line-numbers a {
color: #999; background-color: #fff !important;
} color: #333 !important;
}
.hljs {
display: block; pre.code {
background: #fff; color: black; border-left: 1px solid #bbb;
} }
.hljs-comment, .hll { background-color: #f8f8f8 }
.hljs-template_comment, .c { color: #999988; font-style: italic; }
.hljs-javadoc, .err { color: #a61717; background-color: #e3d2d2; }
.hljs-comment * { .k { font-weight: bold; }
color: #006a00; .o { font-weight: bold; }
} .cm { color: #999988; font-style: italic; }
.cp { color: #999999; font-weight: bold; }
.hljs-keyword, .c1 { color: #999988; font-style: italic; }
.hljs-literal, .cs { color: #999999; font-weight: bold; font-style: italic; }
.nginx .hljs-title { .gd { color: #000000; background-color: #ffdddd; }
color: #aa0d91; .gd .x { color: #000000; background-color: #ffaaaa; }
} .ge { font-style: italic; }
.method, .gr { color: #aa0000; }
.hljs-list .hljs-title, .gh { color: #999999; }
.hljs-tag .hljs-title, .gi { color: #000000; background-color: #ddffdd; }
.setting .hljs-value, .gi .x { color: #000000; background-color: #aaffaa; }
.hljs-winutils, .go { color: #888888; }
.tex .hljs-command, .gp { color: #555555; }
.http .hljs-title, .gs { font-weight: bold; }
.hljs-request, .gu { color: #800080; font-weight: bold; }
.hljs-status { .gt { color: #aa0000; }
color: #008; .kc { font-weight: bold; }
} .kd { font-weight: bold; }
.kn { font-weight: bold; }
.hljs-envvar, .kp { font-weight: bold; }
.tex .hljs-special { .kr { font-weight: bold; }
color: #660; .kt { color: #445588; font-weight: bold; }
} .m { color: #009999; }
.s { color: #dd1144; }
.hljs-string { .n { color: #333333; }
color: #c41a16; .na { color: teal; }
} .nb { color: #0086b3; }
.hljs-tag .hljs-value, .nc { color: #445588; font-weight: bold; }
.hljs-cdata, .no { color: teal; }
.hljs-filter .hljs-argument, .ni { color: purple; }
.hljs-attr_selector, .ne { color: #990000; font-weight: bold; }
.apache .hljs-cbracket, .nf { color: #990000; font-weight: bold; }
.hljs-date, .nn { color: #555555; }
.hljs-regexp { .nt { color: navy; }
color: #080; .nv { color: teal; }
} .ow { font-weight: bold; }
.w { color: #bbbbbb; }
.hljs-sub .hljs-identifier, .mf { color: #009999; }
.hljs-pi, .mh { color: #009999; }
.hljs-tag, .mi { color: #009999; }
.hljs-tag .hljs-keyword, .mo { color: #009999; }
.hljs-decorator, .sb { color: #dd1144; }
.ini .hljs-title, .sc { color: #dd1144; }
.hljs-shebang, .sd { color: #dd1144; }
.hljs-prompt, .s2 { color: #dd1144; }
.hljs-hexcolor, .se { color: #dd1144; }
.hljs-rules .hljs-value, .sh { color: #dd1144; }
.hljs-symbol, .si { color: #dd1144; }
.hljs-symbol .hljs-string, .sx { color: #dd1144; }
.hljs-number, .sr { color: #009926; }
.css .hljs-function, .s1 { color: #dd1144; }
.clojure .hljs-title, .ss { color: #990073; }
.clojure .hljs-built_in, .bp { color: #999999; }
.hljs-function .hljs-title, .vc { color: teal; }
.coffeescript .hljs-attribute { .vg { color: teal; }
color: #1c00cf; .vi { color: teal; }
} .il { color: #009999; }
.gc { color: #999; background-color: #EAF2F5; }
.hljs-class .hljs-title,
.haskell .hljs-type,
.smalltalk .hljs-class,
.hljs-javadoctag,
.hljs-yardoctag,
.hljs-phpdoc,
.hljs-typename,
.hljs-tag .hljs-attribute,
.hljs-doctype,
.hljs-class .hljs-id,
.hljs-built_in,
.setting,
.hljs-params,
.clojure .hljs-attribute {
color: #5c2699;
}
.hljs-variable {
color: #3f6e74;
}
.css .hljs-tag,
.hljs-rules .hljs-property,
.hljs-pseudo,
.hljs-subst {
color: #000;
}
.css .hljs-class,
.css .hljs-id {
color: #9B703F;
}
.hljs-value .hljs-important {
color: #ff7700;
font-weight: bold;
}
.hljs-rules .hljs-keyword {
color: #C5AF75;
}
.hljs-annotation,
.apache .hljs-sqbracket,
.nginx .hljs-built_in {
color: #9B859D;
}
.hljs-preprocessor,
.hljs-preprocessor *,
.hljs-pragma {
color: #643820;
}
.tex .hljs-formula {
background-color: #EEE;
font-style: italic;
}
.diff .hljs-header,
.hljs-chunk {
color: #808080;
font-weight: bold;
}
.diff .hljs-change {
background-color: #BCCFF9;
}
.hljs-addition {
background-color: #BAEEBA;
}
.hljs-deletion {
background-color: #FFC8BD;
}
.hljs-comment .hljs-yardoctag {
font-weight: bold;
}
.method .hljs-id {
color: #000;
}
}
.shadow {
@include box-shadow(0 5px 15px #000);
}
.file-content {
&.code .white {
.highlight {
border-left: 1px solid #eee;
}
}
&.wiki .white {
.highlight, pre, .hljs {
background: #F9F9F9;
}
}
}
.readme-holder .wiki, .note-body, .wiki-holder {
.white {
.highlight, pre, .hljs {
background: #F9F9F9;
}
}
} }
...@@ -65,7 +65,16 @@ ...@@ -65,7 +65,16 @@
max-width: 100%; max-width: 100%;
} }
code { padding: 0 4px; } *:first-child {
margin-top: 0;
}
code {
font-family: $monospace_font;
white-space: pre;
word-wrap: normal;
padding: 0;
}
h1 { h1 {
margin-top: 45px; margin-top: 45px;
......
...@@ -98,6 +98,11 @@ ...@@ -98,6 +98,11 @@
background: #f1f1f1; background: #f1f1f1;
border-left: 1px solid #DDD; border-left: 1px solid #DDD;
} }
td.lines {
code {
font-family: $monospace_font;
}
}
} }
} }
......
...@@ -5,8 +5,9 @@ module ApplicationHelper ...@@ -5,8 +5,9 @@ module ApplicationHelper
COLOR_SCHEMES = { COLOR_SCHEMES = {
1 => 'white', 1 => 'white',
2 => 'dark', 2 => 'dark',
3 => 'solarized-dark', 3 => 'solarized-light',
4 => 'monokai', 4 => 'solarized-dark',
5 => 'monokai',
} }
COLOR_SCHEMES.default = 'white' COLOR_SCHEMES.default = 'white'
...@@ -189,20 +190,6 @@ module ApplicationHelper ...@@ -189,20 +190,6 @@ module ApplicationHelper
BroadcastMessage.current BroadcastMessage.current
end end
def highlight_js(&block)
string = capture(&block)
content_tag :div, class: "highlighted-data #{user_color_scheme_class}" do
content_tag :div, class: 'highlight' do
content_tag :pre do
content_tag :code do
string.html_safe
end
end
end
end
end
def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago')
capture_haml do capture_haml do
haml_tag :time, date.to_s, haml_tag :time, date.to_s,
......
module BlobHelper module BlobHelper
def highlightjs_class(blob_name) def highlight(blob_name, blob_content, nowrap = false)
if no_highlight_files.include?(blob_name.downcase) formatter = Rugments::Formatters::HTML.new(
'no-highlight' nowrap: nowrap,
else cssclass: 'code highlight',
blob_name.downcase lineanchors: true,
lineanchorsid: 'LC'
)
begin
lexer = Rugments::Lexer.guess(filename: blob_name, source: blob_content)
rescue Rugments::Lexer::AmbiguousGuess
lexer = Rugments::Lexers::PlainText
end end
formatter.format(lexer.lex(blob_content)).html_safe
end end
def no_highlight_files def no_highlight_files
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
= i = i
\ \
%td.lines %td.lines
%pre %pre{class: 'code highlight white'}
%code{ class: highlightjs_class(@blob.name) } %code
:erb :erb
<% lines.each do |line| %> <% lines.each do |line| %>
<%= line %> <%= highlight(@blob.name, line, true).html_safe %>
<% end %> <% end %>
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
- else - else
.file-content.code .file-content.code
- unless blob.empty? - unless blob.empty?
= render 'shared/file_hljs', blob: blob = render 'shared/file_highlight', blob: blob
- else - else
.nothing-here-block Empty file .nothing-here-block Empty file
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
%td %td
= commit.message = commit.message
%td %td
#{time_ago_with_tooltip(version.date)} #{time_ago_with_tooltip(version.authored_date)}
%td %td
%strong %strong
= @page.page.wiki.page(@page.page.name, commit.id).try(:format) = @page.page.wiki.page(@page.page.name, commit.id).try(:format)
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
%strong %strong
= blob.filename = blob.filename
.file-content.code.term .file-content.code.term
= render 'shared/file_hljs', blob: blob, first_line_number: blob.startline = render 'shared/file_highlight', blob: blob, first_line_number: blob.startline, user_color_scheme_class: 'white'
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
%strong %strong
= wiki_blob.filename = wiki_blob.filename
.file-content.code.term .file-content.code.term
= render 'shared/file_hljs', blob: wiki_blob, first_line_number: wiki_blob.startline = render 'shared/file_highlight', blob: wiki_blob, first_line_number: wiki_blob.startline, user_color_scheme_class: 'white'
%div.highlighted-data{class: user_color_scheme_class} .file-content.code{class: user_color_scheme_class}
.line-numbers .line-numbers
- if blob.data.present? - if blob.data.present?
- blob.data.lines.to_a.size.times do |index| - blob.data.lines.to_a.size.times do |index|
...@@ -7,7 +7,4 @@ ...@@ -7,7 +7,4 @@
= link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do
%i.fa.fa-link %i.fa.fa-link
= i = i
.highlight = highlight(blob.name, blob.data)
%pre
%code{ class: highlightjs_class(blob.name) }
#{blob.data}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= render_markup(@snippet.file_name, @snippet.data) = render_markup(@snippet.file_name, @snippet.data)
- else - else
.file-content.code .file-content.code
= render 'shared/file_hljs', blob: @snippet = render 'shared/file_highlight', blob: @snippet
- else - else
.file-content.code .file-content.code
.nothing-here-block Empty file .nothing-here-block Empty file
...@@ -21,23 +21,22 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -21,23 +21,22 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
text.gsub("'", "&rsquo;") text.gsub("'", "&rsquo;")
end end
# Stolen from Rugments::Plugins::Redcarpet as this module is not required
# from Rugments's gem root.
def block_code(code, language) def block_code(code, language)
# New lines are placed to fix an rendering issue lexer = Rugments::Lexer.find_fancy(language, code) || Rugments::Lexers::PlainText
# with code wrapped inside <h1> tag for next case:
#
# # Title kinda h1
#
# ruby code here
#
<<-HTML
<div class="highlighted-data #{h.user_color_scheme_class}"> # XXX HACK: Redcarpet strips hard tabs out of code blocks,
<div class="highlight"> # so we assume you're not using leading spaces that aren't tabs,
<pre><code class="#{language}">#{h.send(:html_escape, code)}</code></pre> # and just replace them here.
</div> if lexer.tag == 'make'
</div> code.gsub! /^ /, "\t"
end
HTML formatter = Rugments::Formatters::HTML.new(
cssclass: "code highlight white #{lexer.tag}"
)
formatter.format(lexer.lex(code))
end end
def link(link, title, content) def link(link, title, content)
......
...@@ -26,7 +26,8 @@ describe EventsHelper do ...@@ -26,7 +26,8 @@ describe EventsHelper do
it 'should display the first line of a code block' do it 'should display the first line of a code block' do
input = "```\nCode block\nwith two lines\n```" input = "```\nCode block\nwith two lines\n```"
expected = '<pre><code class="">Code block...</code></pre>' expected = '<pre class="code highlight white plaintext"><code>' \
'Code block...</code></pre>'
expect(event_note(input)).to match(expected) expect(event_note(input)).to match(expected)
end end
......
...@@ -566,7 +566,7 @@ describe GitlabMarkdownHelper do ...@@ -566,7 +566,7 @@ describe GitlabMarkdownHelper do
it "should leave code blocks untouched" do it "should leave code blocks untouched" do
helper.stub(:user_color_scheme_class).and_return(:white) helper.stub(:user_color_scheme_class).and_return(:white)
target_html = "\n<div class=\"highlighted-data white\">\n <div class=\"highlight\">\n <pre><code class=\"\">some code from $#{snippet.id}\nhere too\n</code></pre>\n </div>\n</div>\n\n" target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html
helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
......
...@@ -36,7 +36,7 @@ describe WikiPage do ...@@ -36,7 +36,7 @@ describe WikiPage do
end end
it "sets the version attribute" do it "sets the version attribute" do
@wiki_page.version.should be_a Grit::Commit @wiki_page.version.should be_a Gollum::Git::Commit
end end
end end
end end
......
This source diff could not be displayed because it is too large. You can view the blob instead.
.hljs{display:block;padding:.5em;background:#f0f0f0}.hljs,.hljs-subst,.hljs-tag .hljs-title,.lisp .hljs-title,.clojure .hljs-built_in,.nginx .hljs-title{color:black}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-rules .hljs-value .hljs-number,.hljs-preprocessor,.hljs-pragma,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-aggregate,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute{color:#800}.smartquote,.hljs-comment,.hljs-annotation,.hljs-template_comment,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote{color:#888}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url{color:#080}.hljs-label,.hljs-javadoc,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony{color:#88F}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.hljs-aggregate,.css .hljs-tag,.hljs-javadoctag,.hljs-phpdoc,.hljs-yardoctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.apache .hljs-tag,.go .hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status{font-weight:bold}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:normal}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment