Merge pull request #2095 from riyad/fix-code-highlighting

Fix code highlighting
This commit is contained in:
Dmitriy Zaporozhets 2012-11-27 14:17:32 -08:00
commit 7acd060400
7 changed files with 26 additions and 18 deletions

View file

@ -95,8 +95,8 @@
pre {
padding:0;
margin:0;
background:none;
border:none;
border-radius: 0;
}
}
}
@ -142,8 +142,8 @@
table-layout: fixed;
pre {
background: none;
border: none;
border-radius: 0;
font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace;
font-size: 12px !important;
line-height: 16px !important;

View file

@ -1,6 +1,8 @@
.black .lines .highlight {
background: #333;
pre { color: #eee; }
.black .highlight {
pre {
background-color: #333;
color: #eee;
}
.hll { display: block; background-color: darken($hover, 65%) }
.c { color: #888888; font-style: italic } /* Comment */

View file

@ -1,6 +1,8 @@
.white .lines .highlight {
background: white;
pre { color: #333; }
.white .highlight {
pre {
background-color: #fff;
color: #333;
}
.hll { display: block; background-color: $hover }
.c { color: #888888; font-style: italic } /* Comment */

View file

@ -126,6 +126,10 @@ module ApplicationHelper
Gitlab::Theme.css_class_by_id(current_user.try(:theme_id))
end
def user_color_scheme_class
current_user.dark_scheme ? :black : :white
end
def show_last_push_widget?(event)
event &&
event.last_push_to_non_root? &&

View file

@ -6,8 +6,7 @@
= link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank"
.file_content.code
- unless @snippet.content.empty?
%div{class: current_user.dark_scheme ? "black" : "white"}
:preserve
#{raw @snippet.colorize(formatter: :gitlab)}
%div{class: user_color_scheme_class}
= raw @snippet.colorize(formatter: :gitlab)
- else
%p.nothing_here_message Empty file

View file

@ -8,8 +8,7 @@
- else
.file_content.code
- unless blob.empty?
%div{class: current_user.dark_scheme ? "black" : "white"}
= preserve do
= raw blob.colorize(formatter: :gitlab)
%div{class: user_color_scheme_class}
= raw blob.colorize(formatter: :gitlab)
- else
%p.nothing_here_message Empty file

View file

@ -12,10 +12,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def block_code(code, language)
options = { options: {encoding: 'utf-8'} }
if Pygments::Lexer.find(language)
Pygments.highlight(code, options.merge(lexer: language.downcase))
else
Pygments.highlight(code, options)
h.content_tag :div, class: h.user_color_scheme_class do
if Pygments::Lexer.find(language)
Pygments.highlight(code, options.merge(lexer: language.downcase))
else
Pygments.highlight(code, options)
end.html_safe
end
end