Skip to content

Commit

Permalink
fix: enabling bold emphasis
Browse files Browse the repository at this point in the history
  • Loading branch information
clatapie committed Dec 23, 2024
1 parent 7590cc9 commit ccc90ab
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/pyconverter/xml2py/ast_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,10 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
)

items.append(rst_item)
return "\n".join(items)

rst_list_item = "\n".join(items)
rst_list_item = rst_list_item.replace("*", "\*")
return rst_list_item


class FileName(Element):
Expand Down Expand Up @@ -889,7 +892,7 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None):

if self.role == "bold":
# TODO: this isn't the correct way of making text bold
content = f"{self[0]} "
content = f"**{self[0]}** "
elif self.role == "italic":
# TODO: this isn't the correct way of making text itallic
content = f"{self[0]} "
Expand Down Expand Up @@ -1074,7 +1077,8 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
)
active_items.append(rst_item)

return "\n".join(active_items) + "\n"
rst_varlist = "\n".join(active_items) + "\n"
return rst_varlist

@property
def terms(self):
Expand Down Expand Up @@ -1107,7 +1111,8 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
items.append(item.to_rst(indent=indent))
else:
items.append(str(item))
return "\n".join(items)
rst_refsection = "\n".join(items)
return rst_refsection


class VarlistEntry(Element):
Expand Down Expand Up @@ -1247,7 +1252,8 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
py_term = self.py_term(links=links, base_url=base_url)
if "``" in py_term:
py_term = py_term.replace("``", "")
lines = [f"* ``{py_term}`` - {self.py_text(links=links, base_url=base_url, fcache=fcache)}"]
py_text = self.py_text(links=links, base_url=base_url, fcache=fcache)
lines = [f"* ``{py_term}`` - {py_text}"]
text = "\n".join(lines)
# if 'ID number to which this tip belongs' in text:
# breakpoint()
Expand Down Expand Up @@ -1666,7 +1672,8 @@ def to_rst(self, indent="", links=None, base_url=None):
if len(rst_tbody) > 0:
rows += rst_tbody

return "\n".join(rows)
rst_tgroup = "\n".join(rows)
return rst_tgroup


class Table(Element):
Expand Down Expand Up @@ -2121,7 +2128,8 @@ def to_rst(self, l_head, indent="", links=None, base_url=None):
if type(row[1][0]) == Command:
command = f" * - :ref:`{row[1][0].py_cmd}`"
rst_rows.append(command)
strg = " - " + str(row[2][0])
row_content = str(row[2][0])
strg = f" - {row_content}"
rst_rows.append(strg)

return rst_rows
Expand All @@ -2145,11 +2153,14 @@ def to_rst(self, indent="", links=None, base_url=None, fcache=None):
for item in self:
if isinstance(item, Element):
if item.tag in item_needing_links_base_url:
items.append(item.to_rst(indent, links=links, base_url=base_url))
entry_item = item.to_rst(indent, links=links, base_url=base_url)
else:
items.append(item.to_rst(indent))
entry_item= item.to_rst(indent)
else:
items.append(str(item))
entry_item = str(item)
# entry_item = entry_item.replace("*", "\*")

items.append(entry_item)

if self.morerows is not None:
entry = f":rspan:`{content}` " + " ".join(items)
Expand Down Expand Up @@ -2855,12 +2866,12 @@ def py_docstring(self, custom_functions: CustomFunctions) -> str:
items += [""] + custom_functions.py_examples[self.py_name]
docstr = "\n".join(items)

# final post-processing
def replacer(match):
return match.group().replace("*", r"\*").replace(r"\\*", r"\*")
# # final post-processing
# def replacer(match):
# return match.group().replace("*", r"\*").replace(r"\\*", r"\*")

# sphinx doesn't like asterisk symbols
docstr = re.sub(r"(?<=\S)\*|(\*\S)", replacer, docstr)
# # sphinx doesn't like asterisk symbols
# docstr = re.sub(r"(?<=\S)\*|(\*\S)", replacer, docstr)

for key, value in CONST.items():
docstr = docstr.replace(key, value)
Expand Down

0 comments on commit ccc90ab

Please sign in to comment.