From d6d0979ecfc31c76c58b6f6b8628d455f1a8a440 Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Mon, 28 Dec 2015 23:52:05 +0100 Subject: [PATCH] The code on the lines prepended with a # are hidden, the space of the line remains because of the '\n' in
 tag

---
 src/theme/book.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/theme/book.js b/src/theme/book.js
index 04368f76..862cb324 100644
--- a/src/theme/book.js
+++ b/src/theme/book.js
@@ -112,4 +112,21 @@ $( document ).ready(function() {
 
         $('body').removeClass().addClass(theme);
     }
+
+
+    // Hide Rust code lines prepended with a specific character
+    var hiding_character = "#";
+
+    $("code.language-rust").each(function(i, block){
+        var lines = $(this).html().split("\n");
+
+        for(var n = 0; n < lines.length; n++){
+            if($.trim(lines[n])[0] == hiding_character){
+                lines[n] = "" + lines[n] + ""
+            }
+        }
+        $(this).html(lines.join());
+    });
+
+
 });