From 434a9385522e8ea7a5d0197a30aded58d83b30ea Mon Sep 17 00:00:00 2001 From: Lyuba Zehl Date: Thu, 28 Mar 2024 16:03:24 +0100 Subject: [PATCH] fixing links to subsections --- pipeline/instance.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pipeline/instance.py b/pipeline/instance.py index 44413b3..8641c4e 100644 --- a/pipeline/instance.py +++ b/pipeline/instance.py @@ -42,6 +42,11 @@ def _build_plurals(self, term: str) -> str: else: return f"{term}s" + def _replace_multi(self, term:str, old:List[str], new:str) -> str: + for letter in old: + term.replace(letter, new) + return term + def _build_single_instance_link(self, instanceReference:Dict) -> str: # get instance identity and create instance heading instance_id = instanceReference["@id"] @@ -66,7 +71,7 @@ def _build_single_instance_link(self, instanceReference:Dict) -> str: page_heading = instance_type # create link and return RST hyperlink - link = os.path.join(link_dir, f"{page_heading}.html#{instance_heading}") + link = os.path.join(link_dir, f"{page_heading}.html#{self._replace_multi(instance_heading, ['_', '.'], '-')}") return f"`{instance_id.split('/')[-1]} <{link}>`_" def _build_multi_instance_links(self, instanceReferenceList:List) -> str: