diff options
Diffstat (limited to '')
-rw-r--r-- | _plugins/add-link-to-plaintext-code-block.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/_plugins/add-link-to-plaintext-code-block.rb b/_plugins/add-link-to-plaintext-code-block.rb new file mode 100644 index 0000000..461102e --- /dev/null +++ b/_plugins/add-link-to-plaintext-code-block.rb @@ -0,0 +1,14 @@ +# </code></pre></div></div> +Jekyll::Hooks.register :documents, :post_render do |doc| + if doc.output_ext == ".html" + 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 |