diff options
Diffstat (limited to '')
-rw-r--r-- | _plugins/add-anchor-to-header-from-header-id.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/_plugins/add-anchor-to-header-from-header-id.rb b/_plugins/add-anchor-to-header-from-header-id.rb new file mode 100644 index 0000000..8c100b0 --- /dev/null +++ b/_plugins/add-anchor-to-header-from-header-id.rb @@ -0,0 +1,9 @@ +Jekyll::Hooks.register :documents, :post_render do |doc| + if doc.output_ext == ".html" + doc.output = + doc.output.gsub( + /<h([1-6])(.*?)id="([\w-]+)"(.*?)>(.*?)<\/h[1-6]>/, + '<a class="header-anchor" id="\3-header-anchor" href="#\3"><h\1\2id="\3"\4>\5<img class="simple-icon" src="/images/link.svg" aria-hidden="true" /></h\1></a>' + ) + end +end |