]> cat aescling's git repositories - mastodon.git/commitdiff
Respect original ID with ToC (#11895)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Fri, 20 Sep 2019 15:13:45 +0000 (00:13 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 20 Sep 2019 15:13:44 +0000 (17:13 +0200)
app/lib/toc_generator.rb

index c6e17955790283d3c0a7f07b483c0a7ae56a1aae..351675a5cd0877f1646e9b68ee45bb5e893abbc4 100644 (file)
@@ -45,7 +45,7 @@ class TOCGenerator
     parsed_html.traverse do |node|
       next unless TARGET_ELEMENTS.include?(node.name)
 
-      anchor = node.text.parameterize
+      anchor = node['id'] || node.text.parameterize
       @slugs[anchor] += 1
       anchor = "#{anchor}-#{@slugs[anchor]}" if @slugs[anchor] > 1