Commit 891ea6f6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve highlight for notes

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 86e4f6e0
...@@ -56,7 +56,7 @@ class Dispatcher ...@@ -56,7 +56,7 @@ class Dispatcher
new SearchAutocomplete(path, project_id, project_ref) new SearchAutocomplete(path, project_id, project_ref)
initHighlight: -> initHighlight: ->
$('pre code').each (i, e) -> $('.highlight pre code').each (i, e) ->
hljs.highlightBlock(e) hljs.highlightBlock(e)
$(e).html($.map($(e).html().split("\n"), (line, i) -> $(e).html($.map($(e).html().split("\n"), (line, i) ->
"<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>" "<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>"
......
...@@ -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
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
table-layout: fixed; table-layout: fixed;
pre { pre {
padding: 10px;
border: none; border: none;
border-radius: 0; border-radius: 0;
font-family: $monospace_font; font-family: $monospace_font;
...@@ -57,10 +58,6 @@ ...@@ -57,10 +58,6 @@
pre { pre {
white-space: pre; white-space: pre;
word-wrap: normal; word-wrap: normal;
.line {
padding: 0 10px;
}
} }
} }
} }
...@@ -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;
......
...@@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
<div class="highlighted-data #{h.user_color_scheme_class}"> <div class="highlighted-data #{h.user_color_scheme_class}">
<div class="highlight"> <div class="highlight">
<pre> <pre><code class="#{language}">#{code}</code></pre>
<code class="#{language}">#{code}</code>
</pre>
</div> </div>
</div> </div>
......
...@@ -378,7 +378,7 @@ describe GitlabMarkdownHelper do ...@@ -378,7 +378,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>\n <code class=\"\">some code from $#{snippet.id}\nhere too\n</code>\n </pre>\n </div>\n</div>\n\n" 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 == 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
......
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