Ensure referred li items has anchors

Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: gtema <artem.goncharov@gmail.com>
Co-committed-by: gtema <artem.goncharov@gmail.com>
This commit is contained in:
gtema 2022-11-15 06:39:27 +00:00 committed by zuul
parent a96a12ecf1
commit 2d3c7b3e97

View File

@ -261,8 +261,21 @@ class OTCDocConvertor:
underline.unwrap()
for li in soup.body.find_all("li"):
if not li.get("id"):
continue
local_ref = li.get("id").lower()
# Delete li ID to prevent broken RST containers
del li["id"]
if (
self.is_element_referred(local_ref, file_name)
and local_ref not in page_anchors
):
# LI item referred, but no anchor present
logging.debug("Adding missing li %s anchor", local_ref)
li.insert(0, self.make_label(soup, local_ref))
page_anchors.add(local_ref)
# Sometimes we have code blocks with line numbers.
# <div class="codecoloring" codetype="xxx"><table class="xxx">
# <tr><td class="linenos"><div class="linenodiv"><pre>1