Commit 891ea6f6e66c753d9a2f7a4e261f4d37e118c253

Authored by Dmitriy Zaporozhets
1 parent 86e4f6e0

Improve highlight for notes

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/javascripts/dispatcher.js.coffee
... ... @@ -56,7 +56,7 @@ class Dispatcher
56 56 new SearchAutocomplete(path, project_id, project_ref)
57 57  
58 58 initHighlight: ->
59   - $('pre code').each (i, e) ->
  59 + $('.highlight pre code').each (i, e) ->
60 60 hljs.highlightBlock(e)
61 61 $(e).html($.map($(e).html().split("\n"), (line, i) ->
62 62 "<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>"
... ...
app/assets/javascripts/notes.js.coffee
... ... @@ -94,6 +94,9 @@ class Notes
94 94 if @isNewNote(note)
95 95 @note_ids.push(note.id)
96 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 256 updateNote: (xhr, note, status) =>
254 257 note_li = $("#note_" + note.id)
255 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 264 Called in response to clicking the edit note link
... ...
app/assets/stylesheets/generic/highlight.scss
... ... @@ -6,6 +6,7 @@
6 6 table-layout: fixed;
7 7  
8 8 pre {
  9 + padding: 10px;
9 10 border: none;
10 11 border-radius: 0;
11 12 font-family: $monospace_font;
... ... @@ -57,10 +58,6 @@
57 58 pre {
58 59 white-space: pre;
59 60 word-wrap: normal;
60   -
61   - .line {
62   - padding: 0 10px;
63   - }
64 61 }
65 62 }
66 63 }
... ...
app/assets/stylesheets/main/mixins.scss
... ... @@ -128,7 +128,7 @@
128 128 }
129 129 }
130 130  
131   - code {
  131 + p > code {
132 132 font-size: inherit;
133 133 font-weight: inherit;
134 134 color: #555;
... ...
app/assets/stylesheets/sections/notes.scss
... ... @@ -92,10 +92,6 @@ ul.notes {
92 92 .note-body {
93 93 @include md-typography;
94 94 margin-left: 45px;
95   -
96   - .highlight {
97   - @include border-radius(4px);
98   - }
99 95 }
100 96 .note-header {
101 97 padding-bottom: 5px;
... ...
lib/redcarpet/render/gitlab_html.rb
... ... @@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML &lt; Redcarpet::Render::HTML
23 23  
24 24 <div class="highlighted-data #{h.user_color_scheme_class}">
25 25 <div class="highlight">
26   - <pre>
27   - <code class="#{language}">#{code}</code>
28   - </pre>
  26 + <pre><code class="#{language}">#{code}</code></pre>
29 27 </div>
30 28 </div>
31 29  
... ...
spec/helpers/gitlab_markdown_helper_spec.rb
... ... @@ -378,7 +378,7 @@ describe GitlabMarkdownHelper do
378 378 it "should leave code blocks untouched" do
379 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 383 helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html
384 384 helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
... ...