Skip to content

Commit 63716e3

Browse files
committed
fix: image rendering + cleanup
1 parent 89a39a1 commit 63716e3

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/pyconverter/xml2py/ast_tree.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -848,32 +848,33 @@ def ponctuation_whitespace(text, ponctuation):
848848
if extra_space:
849849
for character in list(set(extra_space)): # remove duplicates in extra_space list
850850
before_space = character[:-1].strip()
851-
regex_before_space = before_space
852-
if "*" in before_space:
853-
regex_before_space = regex_before_space.replace("*", r"\*")
854-
if "?" in before_space:
855-
regex_before_space = regex_before_space.replace("?", r"\?")
856-
if "+" in before_space:
857-
regex_before_space = regex_before_space.replace("+", r"\+")
858-
if ")" in before_space:
859-
regex_before_space = regex_before_space.replace(")", r"\)")
860-
if "(" in before_space:
861-
regex_before_space = regex_before_space.replace("(", r"\(")
862-
if "[" in before_space:
863-
regex_before_space = regex_before_space.replace("[", r"\[")
864-
if "]" in before_space:
865-
regex_before_space = regex_before_space.replace("]", r"\]")
866-
if "." in before_space:
867-
regex_before_space = regex_before_space.replace(".", r"\.")
868-
if "$" in before_space:
869-
regex_before_space = regex_before_space.replace("$", r"\$")
870-
pattern = r"{regex_before_space}\h+\{ponctuation}".format(
871-
regex_before_space=regex_before_space, ponctuation=ponctuation
872-
)
873-
repl = r"{before_space}{ponctuation}".format(
874-
before_space=before_space, ponctuation=ponctuation
875-
)
876-
text = re.sub(pattern, repl, text)
851+
if before_space[:2] != ".." and before_space[-2:] != "::": # skip RST directives
852+
regex_before_space = before_space
853+
if "*" in before_space:
854+
regex_before_space = regex_before_space.replace("*", r"\*")
855+
if "?" in before_space:
856+
regex_before_space = regex_before_space.replace("?", r"\?")
857+
if "+" in before_space:
858+
regex_before_space = regex_before_space.replace("+", r"\+")
859+
if ")" in before_space:
860+
regex_before_space = regex_before_space.replace(")", r"\)")
861+
if "(" in before_space:
862+
regex_before_space = regex_before_space.replace("(", r"\(")
863+
if "[" in before_space:
864+
regex_before_space = regex_before_space.replace("[", r"\[")
865+
if "]" in before_space:
866+
regex_before_space = regex_before_space.replace("]", r"\]")
867+
if "." in before_space:
868+
regex_before_space = regex_before_space.replace(".", r"\.")
869+
if "$" in before_space:
870+
regex_before_space = regex_before_space.replace("$", r"\$")
871+
pattern = r"{regex_before_space}\h+\{ponctuation}".format(
872+
regex_before_space=regex_before_space, ponctuation=ponctuation
873+
)
874+
repl = r"{before_space}{ponctuation}".format(
875+
before_space=before_space, ponctuation=ponctuation
876+
)
877+
text = re.sub(pattern, repl, text)
877878
return text
878879

879880

src/pyconverter/xml2py/writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ def add_additional_source_files(
365365
content = fid.read()
366366
method_names = re.findall(pat.DEF_METHOD, content)
367367
package_structure[module_name][class_file_name][1].extend(method_names)
368-
print(module_name, class_file_name, class_name, method_names)
369368
return package_structure
370369

371370

0 commit comments

Comments
 (0)