Skip to content

Commit 72cea31

Browse files
committed
Assign an id to anchor targets
1 parent 2360025 commit 72cea31

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

_plugins/tocGenerator.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def toc_generate(html)
4747
h2s.map.each do |h2|
4848
inner_section += 1;
4949
anchor_id = anchor_prefix + toc_level.to_s + '-' + toc_section.to_s + '-' + inner_section.to_s
50-
# Insert before element the anchor used by TOC
51-
h2.before("<a name=\"#{anchor_id}\"></a>")
50+
h2['id'] = "#{anchor_id}"
5251

5352
level_html += create_level_html(anchor_id,
5453
toc_level + 1,
@@ -61,8 +60,7 @@ def toc_generate(html)
6160
level_html = '<ul>' + level_html + '</ul>';
6261
end
6362
anchor_id = anchor_prefix + toc_level.to_s + '-' + toc_section.to_s;
64-
# Insert before element the anchor used by TOC
65-
h1.before("<a name=\"#{anchor_id}\"></a>")
63+
h1['id'] = "#{anchor_id}"
6664

6765
toc_html += create_level_html(anchor_id,
6866
toc_level,

0 commit comments

Comments
 (0)