fix_relative_text_links: Allow hrefs to name anchors as well as id.

This commit is contained in:
Jim Miller 2026-04-18 12:58:46 -05:00
parent c730aa2f68
commit 97d37fcfc1

View file

@ -833,7 +833,9 @@ try to download.</p>
## handle identifiers that otherwise appear to be
## selectors themselves. #966
try:
if href[0] == "#" and soup.select_one("[id='%s']"%href[1:]):
# logger.debug("Search for internal link anchor href:(%s)"%href)
if href[0] == "#" and soup.select_one("[id='%s'], [name='%s']"%(href[1:],href[1:])):
# logger.debug("Found internal link anchor href:(%s)"%href)
hrefurl = href
except Exception as e:
logger.debug("Search for internal link anchor failed href:(%s)"%href)