Skip to content

Commit

Permalink
Don't link keyword name in table
Browse files Browse the repository at this point in the history
  • Loading branch information
hakonhagland committed Nov 7, 2024
1 parent 2407911 commit 517926c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parts/meta/kw_uri_map.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ PVCO __RefHeading___Toc325700_501926209
PVDG __RefHeading___Toc104056_57619843
PVDO __RefHeading___Toc45803_719036256
PVDS __RefHeading___Toc104058_57619843
PVSOL __RefHeading___Toc414279_1093985484
PVTSOL __RefHeading___Toc414279_1093985484
PVTG __RefHeading___Toc104060_57619843
PVTGW __RefHeading___Toc355649_3149455253
PVTGWO __RefHeading___Toc356776_4176551521
Expand Down
7 changes: 6 additions & 1 deletion scripts/python/src/fodt/keyword_linker2.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def characters(self, content: str):
if self.office_body_found:
if self.in_p and (not self.in_a) and (not self.not_keyword):
if not self.is_example_p[-1]:
content = self.regex.sub(self.replace_match_function, content)
if not self.is_table_caption(content):
content = self.regex.sub(self.replace_match_function, content)
self.content.write(content)

def collect_style(self, attrs: xml.sax.xmlreader.AttributesImpl) -> None:
Expand Down Expand Up @@ -99,6 +100,10 @@ def get_content(self) -> str:
def get_num_links_inserted(self) -> int:
return self.num_links_inserted

def is_table_caption(self, content: str) -> bool:
# Check if the content is a specific table caption, in that case we should not insert links
return re.search(rf'{re.escape(self.keyword_name)} Keyword Description', content)

def replace_match_function(self, match: re.Match) -> str:
keyword = match.group(0)
uri = self.kw_uri_map[keyword]
Expand Down

0 comments on commit 517926c

Please sign in to comment.