Commit 891ea6f6e66c753d9a2f7a4e261f4d37e118c253
1 parent
86e4f6e0
Exists in
spb-stable
and in
3 other branches
Improve highlight for notes
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
7 changed files
with
11 additions
and
14 deletions
Show diff stats
app/assets/javascripts/dispatcher.js.coffee
@@ -56,7 +56,7 @@ class Dispatcher | @@ -56,7 +56,7 @@ class Dispatcher | ||
56 | new SearchAutocomplete(path, project_id, project_ref) | 56 | new SearchAutocomplete(path, project_id, project_ref) |
57 | 57 | ||
58 | initHighlight: -> | 58 | initHighlight: -> |
59 | - $('pre code').each (i, e) -> | 59 | + $('.highlight pre code').each (i, e) -> |
60 | hljs.highlightBlock(e) | 60 | hljs.highlightBlock(e) |
61 | $(e).html($.map($(e).html().split("\n"), (line, i) -> | 61 | $(e).html($.map($(e).html().split("\n"), (line, i) -> |
62 | "<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>" | 62 | "<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>" |
app/assets/javascripts/notes.js.coffee
@@ -94,6 +94,9 @@ class Notes | @@ -94,6 +94,9 @@ class Notes | ||
94 | if @isNewNote(note) | 94 | if @isNewNote(note) |
95 | @note_ids.push(note.id) | 95 | @note_ids.push(note.id) |
96 | $('ul.main-notes-list').append(note.html) | 96 | $('ul.main-notes-list').append(note.html) |
97 | + code = "#note_" + note.id + " .highlight pre code" | ||
98 | + $(code).each (i, e) -> | ||
99 | + hljs.highlightBlock(e) | ||
97 | 100 | ||
98 | 101 | ||
99 | ### | 102 | ### |
@@ -253,6 +256,9 @@ class Notes | @@ -253,6 +256,9 @@ class Notes | ||
253 | updateNote: (xhr, note, status) => | 256 | updateNote: (xhr, note, status) => |
254 | note_li = $("#note_" + note.id) | 257 | note_li = $("#note_" + note.id) |
255 | note_li.replaceWith(note.html) | 258 | note_li.replaceWith(note.html) |
259 | + code = "#note_" + note.id + " .highlight pre code" | ||
260 | + $(code).each (i, e) -> | ||
261 | + hljs.highlightBlock(e) | ||
256 | 262 | ||
257 | ### | 263 | ### |
258 | Called in response to clicking the edit note link | 264 | Called in response to clicking the edit note link |
app/assets/stylesheets/generic/highlight.scss
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | table-layout: fixed; | 6 | table-layout: fixed; |
7 | 7 | ||
8 | pre { | 8 | pre { |
9 | + padding: 10px; | ||
9 | border: none; | 10 | border: none; |
10 | border-radius: 0; | 11 | border-radius: 0; |
11 | font-family: $monospace_font; | 12 | font-family: $monospace_font; |
@@ -57,10 +58,6 @@ | @@ -57,10 +58,6 @@ | ||
57 | pre { | 58 | pre { |
58 | white-space: pre; | 59 | white-space: pre; |
59 | word-wrap: normal; | 60 | word-wrap: normal; |
60 | - | ||
61 | - .line { | ||
62 | - padding: 0 10px; | ||
63 | - } | ||
64 | } | 61 | } |
65 | } | 62 | } |
66 | } | 63 | } |
app/assets/stylesheets/main/mixins.scss
app/assets/stylesheets/sections/notes.scss
@@ -92,10 +92,6 @@ ul.notes { | @@ -92,10 +92,6 @@ ul.notes { | ||
92 | .note-body { | 92 | .note-body { |
93 | @include md-typography; | 93 | @include md-typography; |
94 | margin-left: 45px; | 94 | margin-left: 45px; |
95 | - | ||
96 | - .highlight { | ||
97 | - @include border-radius(4px); | ||
98 | - } | ||
99 | } | 95 | } |
100 | .note-header { | 96 | .note-header { |
101 | padding-bottom: 5px; | 97 | padding-bottom: 5px; |
lib/redcarpet/render/gitlab_html.rb
@@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML | @@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML | ||
23 | 23 | ||
24 | <div class="highlighted-data #{h.user_color_scheme_class}"> | 24 | <div class="highlighted-data #{h.user_color_scheme_class}"> |
25 | <div class="highlight"> | 25 | <div class="highlight"> |
26 | - <pre> | ||
27 | - <code class="#{language}">#{code}</code> | ||
28 | - </pre> | 26 | + <pre><code class="#{language}">#{code}</code></pre> |
29 | </div> | 27 | </div> |
30 | </div> | 28 | </div> |
31 | 29 |
spec/helpers/gitlab_markdown_helper_spec.rb
@@ -378,7 +378,7 @@ describe GitlabMarkdownHelper do | @@ -378,7 +378,7 @@ describe GitlabMarkdownHelper do | ||
378 | it "should leave code blocks untouched" do | 378 | it "should leave code blocks untouched" do |
379 | helper.stub(:user_color_scheme_class).and_return(:white) | 379 | helper.stub(:user_color_scheme_class).and_return(:white) |
380 | 380 | ||
381 | - target_html = "\n<div class=\"highlighted-data white\">\n <div class=\"highlight\">\n <pre>\n <code class=\"\">some code from $#{snippet.id}\nhere too\n</code>\n </pre>\n </div>\n</div>\n\n" | 381 | + 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" |
382 | 382 | ||
383 | helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html | 383 | helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html |
384 | helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html | 384 | helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html |