Skip to content

Commit 72d0d05

Browse files
Copilotdscho
andcommitted
Address PR feedback: better variable name and regex simplification
Co-authored-by: dscho <[email protected]>
1 parent 35aaf7c commit 72d0d05

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

script/update-docs.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ def index_l10n_doc(filter_tags, doc_list, get_content)
174174

175175
# HTML anchor on hdlist1 (i.e. command options)
176176
html.gsub!(/<dt class="hdlist1">(.*?)<\/dt>/) do |_m|
177-
dt_content = $1
178-
text = dt_content.gsub(/<\/?[^>]+>/, "").tr("^A-Za-z0-9-", "")
177+
inner_html = $1
178+
text = inner_html.gsub(/<\/?[^>]+>/, "").tr("^A-Za-z0-9-", "")
179179
# use txt_path for backward compatibility of already-existing
180180
# deep links shared across the interwebs.
181181
anchor = "#{txt_path}-#{text}"
182182
# handle anchor collisions by appending -1
183183
anchor += "-1" while ids.include?(anchor)
184184
ids.add(anchor)
185185

186-
"<dt class=\"hdlist1\" id=\"#{anchor}\"> <a class=\"anchor\" href=\"##{anchor}\"></a>#{$1} </dt>"
186+
"<dt class=\"hdlist1\" id=\"#{anchor}\"> <a class=\"anchor\" href=\"##{anchor}\"></a>#{inner_html} </dt>"
187187
end
188188
# Make links relative
189189
html.gsub!(/(<a href=['"])\/([^'"]*)/) do |match|
@@ -466,15 +466,15 @@ def index_doc(filter_tags, doc_list, get_content)
466466
end
467467
# HTML anchor on hdlist1 (i.e. command options)
468468
html.gsub!(/<dt class="hdlist1">(.*?)<\/dt>/) do |_m|
469-
dt_content = $1
470-
text = dt_content.gsub(/<\/?[^>]+>/, "").tr("^A-Za-z0-9-", "")
469+
inner_html = $1
470+
text = inner_html.gsub(/<[^>]+>/, "").tr("^A-Za-z0-9-", "")
471471
# use txt_path for backward compatibility of already-existing
472472
# deep links shared across the interwebs.
473473
anchor = "#{txt_path}-#{text}"
474474
# handle anchor collisions by appending -1
475475
anchor += "-1" while ids.include?(anchor)
476476
ids.add(anchor)
477-
"<dt class=\"hdlist1\" id=\"#{anchor}\"> <a class=\"anchor\" href=\"##{anchor}\"></a>#{$1} </dt>"
477+
"<dt class=\"hdlist1\" id=\"#{anchor}\"> <a class=\"anchor\" href=\"##{anchor}\"></a>#{inner_html} </dt>"
478478
end
479479
# Make links relative
480480
html.gsub!(/(<a href=['"])\/([^'"]*)/) do |relurl|

0 commit comments

Comments
 (0)