aboutsummaryrefslogblamecommitdiff
path: root/_plugins/add-link-to-plaintext-code-block.rb
blob: 4c15d3321c297b925cf4d140f823cbd0c069601c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
                                                        
                                                     










                                                                              
Jekyll::Hooks.register :documents, :post_render do |doc|
  if doc.output_ext == ".html" && doc.type != :slides
    code_block_counter = 1
    doc.output = doc.output.gsub(/(<\/code><\/pre><\/div><\/div>)/) do |match|
      res = match +
              '<div class="plaintext-link"><a href="' +
              "#{doc.url}.#{code_block_counter}.txt" +
              '">plaintext</a></div>'
      code_block_counter += 1
      res
    end
  end
end