OSDN Git Service

Fix blob multiline highlight
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Mon, 27 Jan 2014 12:21:40 +0000 (14:21 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Mon, 27 Jan 2014 12:21:40 +0000 (14:21 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/javascripts/blob.js.coffee
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/main.js.coffee
app/assets/stylesheets/generic/highlight.scss
app/assets/stylesheets/highlight/dark.scss
app/assets/stylesheets/highlight/monokai.scss
app/assets/stylesheets/highlight/solarized_dark.scss
app/assets/stylesheets/highlight/white.scss

index 6cdfc18..584f6fa 100644 (file)
@@ -64,7 +64,7 @@ class BlobView
         nodes.attr("id", hash)
 
     # 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
     highlightBlobLines()
index 8ea302f..3ae6d32 100644 (file)
@@ -4,6 +4,7 @@ $ ->
 class Dispatcher
   constructor: () ->
     @initSearch()
+    @initHighlight()
     @initPageScripts()
 
   initPageScripts: ->
@@ -53,3 +54,10 @@ class Dispatcher
     project_ref = opts.data('autocomplete-project-ref')
 
     new SearchAutocomplete(path, project_id, project_ref)
+
+  initHighlight: ->
+    $('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"))
index dd71a4a..9cf4dba 100644 (file)
@@ -56,9 +56,6 @@ document.addEventListener("page:fetch", unbindEvents)
 document.addEventListener("page:change", stopSpinner)
 
 $ ->
-  $('pre code').each (i, e) ->
-    hljs.highlightBlock(e)
-
   # Click a .one_click_select field, select the contents
   $(".one_click_select").on 'click', -> $(@).select()
 
index 80b49c6..7614d20 100644 (file)
     code {
       white-space: pre;
       word-wrap: normal;
+      padding: 0;
+
+      .line {
+        display: inline;
+      }
     }
   }
 
index 1d544b3..d370175 100644 (file)
@@ -1,6 +1,10 @@
 .dark {
   background-color: #232323;
 
+  .line.hll {
+    background: #558;
+  }
+
   .highlight{
     border-left: 1px solid #444;
   }
@@ -15,7 +19,6 @@
 
   .hljs {
     display: block;
-    padding: 0.5em;
     background: #232323;
     color: #E6E1DC;
   }
index fb0da7c..1557f82 100644 (file)
@@ -5,6 +5,10 @@
     border-left: 1px solid #444;
   }
 
+  .line.hll {
+    background: #558;
+  }
+
   .line-numbers a {
     color: #666;
   }
@@ -15,7 +19,7 @@
   }
 
   .hljs {
-    display: block; padding: 0.5em;
+    display: block;
     background: #272822;
   }
 
index 694f359..6fd32d2 100644 (file)
@@ -5,6 +5,10 @@
     border-left: 1px solid #113b46;
   }
 
+  .line.hll {
+    background: #000;
+  }
+
   pre {
     background-color: #002B36;
     color: #eee;
@@ -16,7 +20,6 @@
 
   .hljs {
     display: block;
-    padding: 0.5em;
     background: #002b36;
     color: #839496;
   }
index 7eec3da..880387a 100644 (file)
@@ -1,6 +1,10 @@
 .white {
   background-color: #fff;
 
+  .line.hll {
+    background: #FFA;
+  }
+
   .highlight{
     border-left: 1px solid #eee;
   }
@@ -19,7 +23,7 @@
   }
 
   .hljs {
-    display: block; padding: 0.5em;
+    display: block;
     background: #fff; color: black;
   }