Skip to content

Commit 35aaf7c

Browse files
Copilotdscho
andcommitted
Address PR feedback for HTML tag stripping and test improvements
Co-authored-by: dscho <[email protected]>
1 parent 9b168d2 commit 35aaf7c

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

script/update-docs.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ 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-
text = $1.gsub(/<\/?(?:code|placeholder)>/, "").tr("^A-Za-z0-9-", "")
177+
dt_content = $1
178+
text = dt_content.gsub(/<\/?[^>]+>/, "").tr("^A-Za-z0-9-", "")
178179
# use txt_path for backward compatibility of already-existing
179180
# deep links shared across the interwebs.
180181
anchor = "#{txt_path}-#{text}"
@@ -465,7 +466,8 @@ def index_doc(filter_tags, doc_list, get_content)
465466
end
466467
# HTML anchor on hdlist1 (i.e. command options)
467468
html.gsub!(/<dt class="hdlist1">(.*?)<\/dt>/) do |_m|
468-
text = $1.gsub(/<\/?(?:code|placeholder)>/, "").tr("^A-Za-z0-9-", "")
469+
dt_content = $1
470+
text = dt_content.gsub(/<\/?[^>]+>/, "").tr("^A-Za-z0-9-", "")
469471
# use txt_path for backward compatibility of already-existing
470472
# deep links shared across the interwebs.
471473
anchor = "#{txt_path}-#{text}"

tests/git-scm.spec.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,13 @@ test('manual pages', async ({ page }) => {
194194
})
195195

196196
test('anchor links in manual pages', async ({ page }) => {
197-
// Test that anchor links work with different formats (with or without code tags)
198-
await page.goto(`${url}docs/git-clone`)
199-
200-
// Check that old-style anchor links without code tags still work
201-
await page.goto(`${url}docs/git-clone#Documentation/git-clone.txt---recurse-submodulesltpathspecgt`)
197+
// Test that anchor links work without HTML tags
198+
const anchor = '#Documentation/git-clone.txt---recurse-submodulesltpathspecgt'
199+
await page.goto(`${url}docs/git-clone${anchor}`)
202200

203201
// Find the element that should be highlighted/anchored to
204202
const anchoredElement = page.locator('#Documentation-git-clone\\.txt---recurse-submodulesltpathspecgt')
205203
await expect(anchoredElement).toBeVisible()
206-
207-
// Check that new-style anchor links with code tags also work
208-
await page.goto(`${url}docs/git-clone#Documentation/git-clone.txt-code--recurse-submodulesltpathspecgtcode`)
209-
210-
// Both should point to the same element (after our fix)
211-
const anchoredElementAlt = page.locator('#Documentation-git-clone\\.txt---recurse-submodulesltpathspecgt')
212-
await expect(anchoredElementAlt).toBeVisible()
213204
})
214205

215206
test('book', async ({ page }) => {

0 commit comments

Comments
 (0)