Commit b6454591 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'highlight-js' into 'master'

Highlight.Js

Replace pygments code highlight with client-side library - highlight.js

http://highlightjs.org/
parents 55a662e0 891ea6f6
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
//= require g.raphael-min //= require g.raphael-min
//= require g.bar-min //= require g.bar-min
//= require branch-graph //= require branch-graph
//= require highlightjs.min
//= require ace-src-noconflict/ace //= require ace-src-noconflict/ace
//= require_tree . //= require_tree .
//= require d3 //= require d3
......
...@@ -64,7 +64,7 @@ class BlobView ...@@ -64,7 +64,7 @@ class BlobView
nodes.attr("id", hash) nodes.attr("id", hash)
# initialize multi-line select # initialize multi-line select
$("#tree-content-holder .line_numbers a[id^=L]").on("click", handleMultiSelect) $("#tree-content-holder .line-numbers a[id^=L]").on("click", handleMultiSelect)
# Highlight the correct lines on load # Highlight the correct lines on load
highlightBlobLines() highlightBlobLines()
......
...@@ -4,6 +4,7 @@ $ -> ...@@ -4,6 +4,7 @@ $ ->
class Dispatcher class Dispatcher
constructor: () -> constructor: () ->
@initSearch() @initSearch()
@initHighlight()
@initPageScripts() @initPageScripts()
initPageScripts: -> initPageScripts: ->
...@@ -53,3 +54,10 @@ class Dispatcher ...@@ -53,3 +54,10 @@ 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) ->
hljs.highlightBlock(e)
$(e).html($.map($(e).html().split("\n"), (line, i) ->
"<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>"
).join("\n"))
...@@ -94,6 +94,9 @@ class Notes ...@@ -94,6 +94,9 @@ 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)
### ###
...@@ -253,6 +256,9 @@ class Notes ...@@ -253,6 +256,9 @@ class Notes
updateNote: (xhr, note, status) => updateNote: (xhr, note, status) =>
note_li = $("#note_" + note.id) note_li = $("#note_" + note.id)
note_li.replaceWith(note.html) note_li.replaceWith(note.html)
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
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*= require jquery.ui.gitlab *= require jquery.ui.gitlab
*= require jquery.atwho *= require jquery.atwho
*= require select2 *= require select2
*= require highlightjs.min
*= require_self *= require_self
*/ */
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
@import "generic/lists.scss"; @import "generic/lists.scss";
@import "generic/forms.scss"; @import "generic/forms.scss";
@import "generic/selects.scss"; @import "generic/selects.scss";
@import "generic/highlight.scss";
/** /**
* Page specific styles (issues, projects etc): * Page specific styles (issues, projects etc):
......
...@@ -143,75 +143,6 @@ ...@@ -143,75 +143,6 @@
*/ */
&.code { &.code {
padding: 0; padding: 0;
table.lines {
border: none;
box-shadow: none;
margin: 0px;
padding: 0px;
table-layout: fixed;
pre {
border: none;
border-radius: 0;
font-family: $monospace_font;
font-size: 12px !important;
line-height: 16px !important;
margin: 0;
padding: 10px 0;
}
td {
border: none;
margin: 0;
padding: 0;
vertical-align: top;
&:first-child {
background: #eee;
width: 50px;
}
&:last-child {
}
}
tr:hover {
background: none;
}
pre.line_numbers {
color: #666;
padding: 10px 6px 10px 0;
text-align: right;
background: #EEE;
a {
color: #666;
i {
display: none;
font-size: 14px;
line-height: 14px;
}
&:hover i {
display: inherit;
}
}
}
.highlight {
border-left: 1px solid #DEE2E3;
overflow: auto;
overflow-y: hidden;
pre {
white-space: pre;
word-wrap: normal;
.line {
padding: 0 10px;
}
}
}
}
} }
} }
} }
......
.highlighted-data {
border: none;
box-shadow: none;
margin: 0px;
padding: 0px;
table-layout: fixed;
pre {
padding: 10px;
border: none;
border-radius: 0;
font-family: $monospace_font;
font-size: 12px !important;
line-height: 16px !important;
margin: 0;
code {
white-space: pre;
word-wrap: normal;
padding: 0;
.line {
display: inline;
}
}
}
.hljs {
padding: 0;
}
.line-numbers {
padding: 10px;
text-align: right;
float: left;
width: 60px;
a {
font-family: $monospace_font;
display: block;
font-size: 12px !important;
line-height: 16px !important;
i {
display: none;
}
&:hover i {
display: inline;
}
}
}
.highlight {
overflow: auto;
overflow-y: hidden;
pre {
white-space: pre;
word-wrap: normal;
}
}
}
.dark .highlight { .dark {
background-color: #232323;
background-color: #333; .line.hll {
background: #558;
}
.highlight{
border-left: 1px solid #444;
}
.line-numbers a {
color: #666;
}
pre { pre {
background-color: #333; background-color: #232323;
color: #eee; }
}
.hljs {
.hll { display: block; background-color: darken($hover, 65%) } display: block;
.c { color: #888888; font-style: italic } /* Comment */ background: #232323;
.err { color: #a61717; background-color: #e3d2d2 } /* Error */ color: #E6E1DC;
.k { color: #CDA869; font-weight: bold } /* Keyword */ }
.kp { color: #CDA869; font-weight: bold } /* Keyword */
.cm { color: #888888 } /* Comment.Multiline */ .hljs-comment,
.cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .hljs-template_comment,
.c1 { color: #888888 } /* Comment.Single */ .hljs-javadoc,
.cs { color: #cc0000; font-weight: bold; background-color: transparent } /* Comment.Special */ .hljs-shebang {
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ color: #BC9458;
.ge { font-style: italic } /* Generic.Emph */ font-style: italic;
.gr { color: #aa0000 } /* Generic.Error */ }
.gh { color: #303030 } /* Generic.Heading */
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .hljs-keyword,
.go { color: #888888 } /* Generic.Output */ .ruby .hljs-function .hljs-keyword,
.gp { color: #555555 } /* Generic.Prompt */ .hljs-request,
.gs { font-weight: bold } /* Generic.Strong */ .hljs-status,
.gu { color: #606060 } /* Generic.Subheading */ .nginx .hljs-title,
.gt { color: #aa0000 } /* Generic.Traceback */ .method,
.kc{font-weight: bold;} /* Keyword.Constant */ .hljs-list .hljs-title {
.kd{font-weight: bold;} /* Keyword.Declaration */ color: #C26230;
.kn{font-weight: bold;} /* Keyword.Namespace */ }
.kp{font-weight: bold;} /* Keyword.Pseudo */
.kr{font-weight: bold;} /* Keyword.Reserved */ .hljs-string,
.kt{color: #458;font-weight: bold;} /* Keyword.Type */ .hljs-number,
.m { color: #0000DD; font-weight: bold } /* Literal.Number */ .hljs-regexp,
.p { color: #eee; } .hljs-tag .hljs-value,
.s { color: #0AD; background-color: transparent } /* Literal.String */ .hljs-cdata,
.na{color: #008080;} /* Name.Attribute */ .hljs-filter .hljs-argument,
.nb{color: #0086B3;} /* Name.Builtin */ .hljs-attr_selector,
.nc{color: #ccc;font-weight: bold;} /* Name.Class */ .apache .hljs-cbracket,
.no{color: turquoise;} /* Name.Constant */ .hljs-date,
.ni{color: #800080;} .tex .hljs-command,
.ne{color: #900;font-weight: bold;} /* Name.Exception */ .markdown .hljs-link_label {
.nf{color: #ccc;font-weight: bold;} /* Name.Function */ color: #A5C261;
.nn{color: #79C3E0;font-weight: bold;} /* Name.Namespace */ }
.nt{color: #fc5;} /* Name.Tag */
.nv{color: #FA4;} /* Name.Variable */ .hljs-subst {
.py { color: #336699; font-weight: bold } /* Name.Property */ color: #519F50;
.ow { color: #008800 } /* Operator.Word */ }
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #7AC; font-weight: bold } /* Literal.Number.Float */ .hljs-tag,
.mh { color: #7AC; font-weight: bold } /* Literal.Number.Hex */ .hljs-tag .hljs-keyword,
.mi {color: #099;} /* Literal.Number.Integer */ .hljs-tag .hljs-title,
.mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .hljs-doctype,
.sb { color: #dd2200; background-color: transparent; } /* Literal.String.Backtick */ .hljs-sub .hljs-identifier,
.sc{color: #d14;} /* Literal.String.Char */ .hljs-pi,
.sd { color: #dd2200; background-color: transparent; } /* Literal.String.Doc */ .input_number {
.s2{color: orange;} /* Literal.String.Double */ color: #E8BF6A;
.se{color: orange;} /* Literal.String.Escape */ }
.sh{color: orange;} /* Literal.String.Heredoc */
.si{color: orange;} /* Literal.String.Interpol */ .hljs-identifier {
.sx{color: orange;} /* Literal.String.Other */ color: #D0D0FF;
.sr{color: orange;} /* Literal.String.Regex */ }
.s1{color: orange;} /* Literal.String.Single */
.ss{color: orange;} /* Literal.String.Symbol */ .hljs-class .hljs-title,
.bp { color: #D58 } /* Name.Builtin.Pseudo */ .haskell .hljs-type,
.vc { color: #336699 } /* Name.Variable.Class */ .smalltalk .hljs-class,
.vg { color: #dd7700 } /* Name.Variable.Global */ .hljs-javadoctag,
.vi { color: cyan } .hljs-yardoctag,
} .hljs-phpdoc {
text-decoration: none;
}
.hljs-constant {
color: #DA4939;
}
.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-fg: #f8f8f2; .monokai {
$monokai-comment: #75715e; background-color: #272822;
$monokai-pink: #f92672;
$monokai-blue: #66d9ef;
$monokai-green: #a6e22e;
$monokai-gold: #e6db74;
$monokai-dark: #3b3a32;
$monokai-purple: #ae81ff;
.monokai .highlight { .highlight{
border-left: 1px solid #444;
}
background-color: #272822; .line.hll {
background: #558;
}
.line-numbers a {
color: #666;
}
pre { pre {
background-color: #272822; background-color: #272822;
color: $monokai-fg; color: #f8f8f2;
} }
.hll { background-color: darken($hover, 65%) } .hljs {
.c { color: $monokai-comment } /* Comment */ display: block;
.err { color: $monokai-fg } /* Error */ background: #272822;
.g { color: $monokai-fg } /* Generic */ }
.k { color: $monokai-pink } /* Keyword */
.l { color: $monokai-fg } /* Literal */ .hljs-tag,
.n { color: $monokai-blue } /* Name */ .hljs-tag .hljs-title,
.o { color: $monokai-fg } /* Operator */ .hljs-keyword,
.x { color: $monokai-fg } /* Other */ .hljs-literal,
.p { color: $monokai-fg } /* Punctuation */ .hljs-strong,
.cm { color: $monokai-comment } /* Comment.Multiline */ .hljs-change,
.cp { color: $monokai-comment } /* Comment.Preproc */ .hljs-winutils,
.c1 { color: $monokai-comment } /* Comment.Single */ .hljs-flow,
.cs { color: $monokai-comment } /* Comment.Special */ .lisp .hljs-title,
.gd { color: #8b0807 } /* Generic.Deleted */ .clojure .hljs-built_in,
.ge { color: $monokai-fg; text-decoration: underline } /* Generic.Emph */ .nginx .hljs-title,
.gr { color: $monokai-fg } /* Generic.Error */ .tex .hljs-special {
.gh { color: $monokai-fg; font-weight: bold } /* Generic.Heading */ color: #F92672;
.gi { color: $monokai-fg; font-weight: bold; background-color: #46830c } /* Generic.Inserted */ }
.go { color: $monokai-dark; background-color: #31322c } /* Generic.Output */
.gp { color: $monokai-fg } /* Generic.Prompt */ .hljs {
.gs { color: $monokai-fg } /* Generic.Strong */ color: #DDD;
.gu { color: $monokai-fg; font-weight: bold } /* Generic.Subheading */ }
.gt { color: #f8f8f0; background-color: $monokai-pink } /* Generic.Traceback */
.kc { color: $monokai-purple } /* Keyword.Constant */ .hljs .hljs-constant,
.kd { color: $monokai-pink } /* Keyword.Declaration */ .asciidoc .hljs-code {
.kn { color: $monokai-pink } /* Keyword.Namespace */ color: #66D9EF;
.kp { color: $monokai-pink } /* Keyword.Pseudo */ }
.kr { color: $monokai-pink } /* Keyword.Reserved */
.kt { color: $monokai-fg } /* Keyword.Type */ .hljs-code,
.ld { color: $monokai-fg } /* Literal.Date */ .hljs-class .hljs-title,
.m { color: $monokai-purple } /* Literal.Number */ .hljs-header {
.s { color: $monokai-gold } /* Literal.String */ color: white;
.na { color: $monokai-purple } /* Name.Attribute */ }
.nb { color: $monokai-blue } /* Name.Builtin */
.nc { color: $monokai-fg } /* Name.Class */ .hljs-link_label,
.no { color: $monokai-fg } /* Name.Constant */ .hljs-attribute,
.nd { color: $monokai-fg } /* Name.Decorator */ .hljs-symbol,
.ni { color: $monokai-fg } /* Name.Entity */ .hljs-symbol .hljs-string,
.ne { color: $monokai-fg } /* Name.Exception */ .hljs-value,
.nf { color: $monokai-green } /* Name.Function */ .hljs-regexp {
.nl { color: $monokai-gold } /* Name.Label */ color: #BF79DB;
.nn { color: $monokai-fg } /* Name.Namespace */ }
.nx { color: $monokai-fg } /* Name.Other */
.nt { color: $monokai-pink } /* Name.Tag */ .hljs-link_url,
.nv { color: $monokai-blue; font-style: italic } /* Name.Variable */ .hljs-tag .hljs-value,
.py { color: $monokai-fg } /* Name.Property */ .hljs-string,
.ow { color: $monokai-pink } /* Operator.Word */ .hljs-bullet,
.w { color: $monokai-fg } /* Text.Whitespace */ .hljs-subst,
.mf { color: $monokai-purple } /* Literal.Number.Float */ .hljs-title,
.mh { color: $monokai-purple } /* Literal.Number.Hex */ .hljs-emphasis,
.mi { color: $monokai-purple } /* Literal.Number.Integer */ .haskell .hljs-type,
.mo { color: $monokai-purple } /* Literal.Number.Oct */ .hljs-preprocessor,
.sb { color: $monokai-gold } /* Literal.String.Backtick */ .hljs-pragma,
.sc { color: $monokai-gold } /* Literal.String.Char */ .ruby .hljs-class .hljs-parent,
.sd { color: $monokai-gold } /* Literal.String.Doc */ .hljs-built_in,
.s2 { color: $monokai-gold } /* Literal.String.Double */ .sql .hljs-aggregate,
.se { color: $monokai-gold } /* Literal.String.Escape */ .django .hljs-template_tag,
.sh { color: $monokai-gold } /* Literal.String.Heredoc */ .django .hljs-variable,
.si { color: $monokai-gold } /* Literal.String.Interpol */ .smalltalk .hljs-class,
.sx { color: $monokai-gold } /* Literal.String.Other */ .hljs-javadoc,
.sr { color: $monokai-gold } /* Literal.String.Regex */ .django .hljs-filter .hljs-argument,
.s1 { color: $monokai-gold } /* Literal.String.Single */ .smalltalk .hljs-localvars,
.ss { color: $monokai-gold } /* Literal.String.Symbol */ .smalltalk .hljs-array,
.bp { color: $monokai-fg } /* Name.Builtin.Pseudo */ .hljs-attr_selector,
.vc { color: $monokai-blue; font-style: italic } /* Name.Variable.Class */ .hljs-pseudo,
.vg { color: $monokai-blue; font-style: italic } /* Name.Variable.Global */ .hljs-addition,
.vi { color: $monokai-blue; font-style: italic } /* Name.Variable.Instance */ .hljs-stream,
.il { color: $monokai-purple } /* Literal.Number.Integer.Long */ .hljs-envvar,
} .apache .hljs-tag,
.apache .hljs-cbracket,
.tex .hljs-command,
.hljs-prompt {
color: #A6E22E;
}
.hljs-comment,
.java .hljs-annotation,
.smartquote,
.hljs-blockquote,
.hljs-horizontal_rule,
.python .hljs-decorator,
.hljs-template_comment,
.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 .highlight { .solarized-dark {
background-color: #002B36; background-color: #002B36;
.highlight{
border-left: 1px solid #113b46;
}
.line.hll {
background: #000;
}
pre { pre {
background-color: #002B36; background-color: #002B36;
color: #eee; color: #eee;
} }
.hll { background-color: #073642 } .line-numbers a {
.c { color: #586E75 } /* Comment */ color: #666;
.err { color: #93A1A1 } /* Error */ }
.g { color: #93A1A1 } /* Generic */
.k { color: #859900 } /* Keyword */
.l { color: #93A1A1 } /* Literal */
.n { color: #93A1A1 } /* Name */
.o { color: #859900 } /* Operator */
.x { color: #CB4B16 } /* Other */
.p { color: #93A1A1 } /* Punctuation */
.cm { color: #586E75 } /* Comment.Multiline */
.cp { color: #859900 } /* Comment.Preproc */
.c1 { color: #586E75 } /* Comment.Single */
.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 */
}
.hljs {
display: block;
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 */
.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 */
.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 */
.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 */
.hljs-preprocessor,
.hljs-preprocessor .hljs-keyword,
.hljs-pragma,
.hljs-shebang,
.hljs-symbol,
.hljs-symbol .hljs-string,
.diff .hljs-change,
.hljs-special,
.hljs-attr_selector,
.hljs-subst,
.hljs-cdata,
.clojure .hljs-title,
.css .hljs-pseudo,
.hljs-header {
color: #cb4b16;
}
/* Solarized Red */
.hljs-deletion,
.hljs-important {
color: #dc322f;
}
/* Solarized Violet */
.hljs-link_label {
color: #6c71c4;
}
.tex .hljs-formula {
background: #073642;
}
}
.white .highlight { .white {
background-color: #fff; background-color: #fff;
.line.hll {
background: #FFA;
}
.highlight{
border-left: 1px solid #eee;
}
pre { pre {
background-color: #fff; background-color: #fff;
color: #333; color: #333;
} }
.hll { display: block; background-color: $hover } .hljs {
.c { color: #888888; font-style: italic } /* Comment */ background: #FFF;
.err { color: #a61717; background-color: #e3d2d2 } /* Error */ }
.k { color: #000000; font-weight: bold } /* Keyword */
.cm { color: #888888 } /* Comment.Multiline */ .line-numbers a {
.cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ color: #999;
.c1 { color: #888888 } /* Comment.Single */ }
.cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .hljs {
.ge { font-style: italic } /* Generic.Emph */ display: block;
.gr { color: #aa0000 } /* Generic.Error */ background: #fff; color: black;
.gh { color: #303030 } /* Generic.Heading */ }
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */ .hljs-comment,
.gp { color: #555555 } /* Generic.Prompt */ .hljs-template_comment,
.gs { font-weight: bold } /* Generic.Strong */ .hljs-javadoc,
.gu { color: #606060 } /* Generic.Subheading */ .hljs-comment * {
.gt { color: #aa0000 } /* Generic.Traceback */ color: #006a00;
.kc{font-weight: bold;} /* Keyword.Constant */ }
.kd{font-weight: bold;} /* Keyword.Declaration */
.kn{font-weight: bold;} /* Keyword.Namespace */ .hljs-keyword,
.kp{font-weight: bold;} /* Keyword.Pseudo */ .hljs-literal,
.kr{font-weight: bold;} /* Keyword.Reserved */ .nginx .hljs-title {
.kt{color: #458;font-weight: bold;} /* Keyword.Type */ color: #aa0d91;
.m { color: #0000DD; font-weight: bold } /* Literal.Number */ }
.s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .method,
.na{color: #008080;} /* Name.Attribute */ .hljs-list .hljs-title,
.nb{color: #0086B3;} /* Name.Builtin */ .hljs-tag .hljs-title,
.nc{color: #458;font-weight: bold;} /* Name.Class */ .setting .hljs-value,
.no{color: #008080;} /* Name.Constant */ .hljs-winutils,
.ni{color: #800080;} .tex .hljs-command,
.ne{color: #900;font-weight: bold;} /* Name.Exception */ .http .hljs-title,
.nf{color: #900;font-weight: bold;} /* Name.Function */ .hljs-request,
.nn{color: #005;font-weight: bold;} /* Name.Namespace */ .hljs-status {
.nt{color: #000080;} /* Name.Tag */ color: #008;
.nv{color: #008080;} /* Name.Variable */ }
.py { color: #336699; font-weight: bold } /* Name.Property */
.ow { color: #008800 } /* Operator.Word */ .hljs-envvar,
.w { color: #bbbbbb } /* Text.Whitespace */ .tex .hljs-special {
.mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ color: #660;
.mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ }
.mi {color: #099;} /* Literal.Number.Integer */
.mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .hljs-string {
.sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ color: #c41a16;
.sc{color: #d14;} /* Literal.String.Char */ }
.sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .hljs-tag .hljs-value,
.s2{color: #d14;} /* Literal.String.Double */ .hljs-cdata,
.se{color: #d14;} /* Literal.String.Escape */ .hljs-filter .hljs-argument,
.sh{color: #d14;} /* Literal.String.Heredoc */ .hljs-attr_selector,
.si{color: #d14;} /* Literal.String.Interpol */ .apache .hljs-cbracket,
.sx{color: #d14;} /* Literal.String.Other */ .hljs-date,
.sr{color: #d14;} /* Literal.String.Regex */ .hljs-regexp {
.s1{color: #d14;} /* Literal.String.Single */ color: #080;
.ss{color: #d14;} /* Literal.String.Symbol */ }
.bp { color: #003388 } /* Name.Builtin.Pseudo */
.vc { color: #336699 } /* Name.Variable.Class */ .hljs-sub .hljs-identifier,
.vg { color: #dd7700 } /* Name.Variable.Global */ .hljs-pi,
.vi { color: #3333bb } .hljs-tag,
.hljs-tag .hljs-keyword,
.hljs-decorator,
.ini .hljs-title,
.hljs-shebang,
.hljs-prompt,
.hljs-hexcolor,
.hljs-rules .hljs-value,
.hljs-symbol,
.hljs-symbol .hljs-string,
.hljs-number,
.css .hljs-function,
.clojure .hljs-title,
.clojure .hljs-built_in,
.hljs-function .hljs-title,
.coffeescript .hljs-attribute {
color: #1c00cf;
}
.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 { .shadow {
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
} }
} }
code { p > code {
font-size: inherit; font-size: inherit;
font-weight: inherit; font-weight: inherit;
color: #555; color: #555;
......
...@@ -92,10 +92,6 @@ ul.notes { ...@@ -92,10 +92,6 @@ ul.notes {
.note-body { .note-body {
@include md-typography; @include md-typography;
margin-left: 45px; margin-left: 45px;
.highlight {
@include border-radius(4px);
}
} }
.note-header { .note-header {
padding-bottom: 5px; padding-bottom: 5px;
......
...@@ -203,8 +203,14 @@ module ApplicationHelper ...@@ -203,8 +203,14 @@ module ApplicationHelper
def highlight_js(&block) def highlight_js(&block)
string = capture(&block) string = capture(&block)
content_tag :div, class: user_color_scheme_class do content_tag :div, class: "highlighted-data #{user_color_scheme_class}" do
Pygments::Lexer[:js].highlight(string).html_safe content_tag :div, class: 'highlight' do
content_tag :pre do
content_tag :code do
string.html_safe
end
end
end
end end
end end
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
- else - else
.file-content.code .file-content.code
- unless blob.empty? - unless blob.empty?
%div{class: user_color_scheme_class} = render 'shared/file_hljs', blob: blob
= raw blob.colorize(formatter: :gitlab)
- else - else
%p.nothing_here_message Empty file %p.nothing_here_message Empty file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
= link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-tiny", target: "_blank" = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-tiny", target: "_blank"
.file-content.code .file-content.code
- unless @snippet.content.empty? - unless @snippet.content.empty?
%div{class: user_color_scheme_class} = render 'shared/file_hljs', blob: @snippet
= raw @snippet.colorize(formatter: :gitlab)
- else - else
%p.nothing_here_message Empty file %p.nothing_here_message Empty file
%div.highlighted-data{class: user_color_scheme_class}
.line-numbers
- blob.data.lines.size.times do |index|
- i = index + 1
= link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do
%i.icon-link
= i
.highlight
%pre
%code
= raw blob.data
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
= render_markup(@snippet.file_name, @snippet.data) = render_markup(@snippet.file_name, @snippet.data)
- else - else
.file-content.code .file-content.code
%div{class: user_color_scheme_class} = render 'shared/file_hljs', blob: @snippet
= raw @snippet.colorize(formatter: :gitlab)
- else - else
.file-content.code .file-content.code
%p.nothing_here_message Empty file %p.nothing_here_message Empty file
### Add user as a developer to all projects ### Add user as a developer to all projects
``` ```bash
bundle exec rake gitlab:import:user_to_projects[username@domain.tld] bundle exec rake gitlab:import:user_to_projects[username@domain.tld]
``` ```
...@@ -11,6 +11,6 @@ Notes: ...@@ -11,6 +11,6 @@ Notes:
* admin users are added as masters * admin users are added as masters
``` ```bash
bundle exec rake gitlab:import:all_users_to_all_projects bundle exec rake gitlab:import:all_users_to_all_projects
``` ```
...@@ -12,10 +12,6 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -12,10 +12,6 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end end
def block_code(code, language) def block_code(code, language)
options = { options: {encoding: 'utf-8'} }
lexer = Pygments::Lexer.find(language) # language can be an alias
options.merge!(lexer: lexer.aliases[0].downcase) if lexer # downcase is required
# New lines are placed to fix an rendering issue # New lines are placed to fix an rendering issue
# with code wrapped inside <h1> tag for next case: # with code wrapped inside <h1> tag for next case:
# #
...@@ -25,7 +21,11 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -25,7 +21,11 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
# #
<<-HTML <<-HTML
<div class="#{h.user_color_scheme_class}">#{Pygments.highlight(code, options)}</div> <div class="highlighted-data #{h.user_color_scheme_class}">
<div class="highlight">
<pre><code class="#{language}">#{code}</code></pre>
</div>
</div>
HTML HTML
end end
......
...@@ -378,10 +378,10 @@ describe GitlabMarkdownHelper do ...@@ -378,10 +378,10 @@ 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 = "<div class=\"white\"><div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> <span class=\"err\">$</span><span class=\"mi\">#{snippet.id}</span>" 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"
helper.markdown("\n some code from $#{snippet.id}\n here too\n").should include(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 include(target_html) helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
end end
it "should leave inline code untouched" do it "should leave inline code untouched" do
......
This diff is collapsed.
.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