Browse Source

Add fallback section ID with ToC (#11941)

pull/4/head
Yamagishi Kazutoshi 4 years ago
committed by Eugen Rochko
parent
commit
67bef15e53
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      app/lib/toc_generator.rb

+ 1
- 1
app/lib/toc_generator.rb View File

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

Loading…
Cancel
Save