We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9e3ab41 + 8cc2c37 commit 08a3382Copy full SHA for 08a3382
app/models/page/renderer.rb
@@ -75,6 +75,14 @@ def add_automatic_ids_to_headings(doc)
75
h2_ids = []
76
h3s_with_manual_ids = []
77
78
+ # h1 headers
79
+ doc.search('./h1').each do |header|
80
+ if (id = header['id']).blank?
81
+ id = header['id'] = header.text.to_url
82
+ end
83
84
+
85
+ # h2 headers
86
doc.search('./h2').each do |h2|
87
if (id = h2['id']).blank?
88
id = h2['id'] = h2.text.to_url
spec/models/page/renderer_spec.rb
@@ -8,7 +8,7 @@
8
MD
9
10
html = <<~HTML
11
- <h1>Page title</h1>
+ <h1 id="page-title">Page title</h1>
12
13
<p>Some description</p>
14
HTML
0 commit comments