diff options
Diffstat (limited to '_plugins/add-anchor-to-code-block-line-numbers.rb')
-rw-r--r-- | _plugins/add-anchor-to-code-block-line-numbers.rb | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/_plugins/add-anchor-to-code-block-line-numbers.rb b/_plugins/add-anchor-to-code-block-line-numbers.rb deleted file mode 100644 index ec6f0a8..0000000 --- a/_plugins/add-anchor-to-code-block-line-numbers.rb +++ /dev/null @@ -1,20 +0,0 @@ -PREFIX = '<pre class="lineno">' -POSTFIX = '</pre>' -Jekyll::Hooks.register [:documents, :pages], :post_render do |doc| - if doc.output_ext == ".html" && doc.type != :slides - code_block_counter = 1 - doc.output = doc.output.gsub(/<pre class="lineno">[\n0-9]+<\/pre>/) do |match| - line_numbers = match - .gsub(/<pre class="lineno">([\n0-9]+)<\/pre>/, '\1') - .split("\n") - - anchored_line_numbers_array = line_numbers.map do |n| - id = "B#{code_block_counter}-L#{n}" - "<a class=\"code-line-anchor\" id=\"#{id}\" href=\"##{id}\">#{n}</a>" - end - code_block_counter += 1 - - PREFIX + anchored_line_numbers_array.join("\n") + POSTFIX - end - end -end |