forked from docs/doc-exports
fixing checking of attribute
This commit is contained in:
parent
e463db0379
commit
11ffa0d4d8
@ -265,34 +265,32 @@ class OTCDocConvertor:
|
|||||||
for lnk in soup.body.find_all("a"):
|
for lnk in soup.body.find_all("a"):
|
||||||
if (
|
if (
|
||||||
lnk.string is None
|
lnk.string is None
|
||||||
and hasattr(lnk, "name")
|
and lnk.has_attr("name")
|
||||||
|
and not re.match(r"^li\d+$", lnk.attrs["name"])
|
||||||
|
# anywhere section
|
||||||
|
and not re.match(r".*section\d+$", lnk.attrs["name"])
|
||||||
|
# starts with table
|
||||||
|
and not re.match(r"^table\d+$", lnk.attrs["name"])
|
||||||
):
|
):
|
||||||
if (
|
# Verify this is really called from somewhere:
|
||||||
not re.match(r"^li\d+$", lnk.attrs["name"])
|
local_ref = lnk["name"].lower()
|
||||||
# anywhere section
|
if self.is_element_referred(local_ref, file_name):
|
||||||
and not re.match(r".*section\d+$", lnk.attrs["name"])
|
# We now know something in the document wants this anchor -
|
||||||
# starts with table
|
# replace it with label
|
||||||
and not re.match(r"^table\d+$", lnk.attrs["name"])
|
if local_ref not in page_anchors:
|
||||||
):
|
logging.debug("Adding anchor")
|
||||||
# Verify this is really called from somewhere:
|
lnk.name = "p"
|
||||||
local_ref = lnk["name"].lower()
|
lnk.string = f"..\\_{local_ref}:"
|
||||||
if self.is_element_referred(local_ref, file_name):
|
del lnk["name"]
|
||||||
# We now know something in the document wants this
|
page_anchors.add(local_ref)
|
||||||
# anchor - replace it with label
|
|
||||||
if local_ref not in page_anchors:
|
|
||||||
logging.debug("Adding anchor")
|
|
||||||
lnk.name = "p"
|
|
||||||
lnk.string = f"..\\_{local_ref}:"
|
|
||||||
del lnk["name"]
|
|
||||||
page_anchors.add(local_ref)
|
|
||||||
else:
|
|
||||||
logging.debug(
|
|
||||||
"Not placing replaced anchor %s "
|
|
||||||
" since it already existed",
|
|
||||||
local_ref,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
logging.debug("Dropping unreferred link %s", lnk)
|
logging.debug(
|
||||||
|
"Not placing replaced anchor %s "
|
||||||
|
" since it already existed",
|
||||||
|
local_ref,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logging.debug("Dropping unreferred link %s", lnk)
|
||||||
|
|
||||||
# Undeline element should not be used at all
|
# Undeline element should not be used at all
|
||||||
for underline in soup.body.find_all("u"):
|
for underline in soup.body.find_all("u"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user