From 1643801e434c2c9bb09353998856210a46056f3b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 5 Oct 2024 10:28:12 +0200 Subject: update permalinks + fix indents --- _plugins/toc.rb | 110 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to '_plugins/toc.rb') diff --git a/_plugins/toc.rb b/_plugins/toc.rb index 216341d..3c4f836 100644 --- a/_plugins/toc.rb +++ b/_plugins/toc.rb @@ -1,61 +1,61 @@ require 'nokogiri' module Jekyll - class TOC < Liquid::Tag - def render context - # load HTML into nokogiri - html = context.registers[:page]['content'] - doc = Nokogiri::HTML(html) - - # enumerate over all h1-4 headings - @els = doc.css("h1, h2, h3, h4") - return '
%s
' % [ output_toc ] - end - - def output_toc - # empty toc (this check prevents crash) - return "" if @els.length == 0 - - output = '' - - return output - end - - def el_level el - return Integer(el.name[1..]) - end - end + class TOC < Liquid::Tag + def render context + # load HTML into nokogiri + html = context.registers[:page]['content'] + doc = Nokogiri::HTML(html) + + # enumerate over all h1-4 headings + @els = doc.css("h1, h2, h3, h4") + return '
%s
' % [ output_toc ] + end + + def output_toc + # empty toc (this check prevents crash) + return "" if @els.length == 0 + + output = '' + + return output + end + + def el_level el + return Integer(el.name[1..]) + end + end end Liquid::Template.register_tag('toc', Jekyll::TOC) -- cgit v1.2.3