From: Yamagishi Kazutoshi Date: Mon, 23 Sep 2019 15:25:10 +0000 (+0900) Subject: Add fallback section ID with ToC (#11941) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=67bef15e53a77b6f1557fdd0efa65f3e916c20df;p=mastodon.git Add fallback section ID with ToC (#11941) --- diff --git a/app/lib/toc_generator.rb b/app/lib/toc_generator.rb index 351675a5c..0c8f766ca 100644 --- a/app/lib/toc_generator.rb +++ b/app/lib/toc_generator.rb @@ -45,7 +45,7 @@ class TOCGenerator parsed_html.traverse do |node| next unless TARGET_ELEMENTS.include?(node.name) - anchor = node['id'] || node.text.parameterize + anchor = node['id'] || node.text.parameterize.presence || 'sec' @slugs[anchor] += 1 anchor = "#{anchor}-#{@slugs[anchor]}" if @slugs[anchor] > 1