mirror of https://github.com/eyhc1/rendercv.git
renderer: fix nested command parser
This commit is contained in:
parent
b1fdcb7618
commit
4f9ee4ca6c
|
@ -183,19 +183,15 @@ class LaTeXFile(TemplatedFile):
|
||||||
# ones with \textnormal:
|
# ones with \textnormal:
|
||||||
|
|
||||||
# Find all the nested commands:
|
# Find all the nested commands:
|
||||||
nested_commands = re.findall(
|
nested_commands = re.findall(r"\\textbf{[^}]*?(\\textbf{.*?})", result)
|
||||||
r"\\textbf{[^}]*?(\\textbf{.*?})|\\textit{[^}]*?(\\textit{.*?})"
|
nested_commands += re.findall(r"\\textit{[^}]*?(\\textit{.*?})", result)
|
||||||
r"|\\underline{[^}]*?(\\underline{.*?})",
|
nested_commands += re.findall(r"\\underline{[^}]*?(\\underline{.*?})", result)
|
||||||
result,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Replace the inner commands with \textnormal:
|
# Replace the inner commands with \textnormal:
|
||||||
for nested_command in nested_commands:
|
for nested_command in nested_commands:
|
||||||
new_command = (
|
new_command = nested_command.replace("textbf", "textnormal")
|
||||||
nested_command.replace("textbf", "textnormal")
|
new_command = new_command.replace("textit", "textnormal")
|
||||||
.replace("textit", "textnormal")
|
new_command = new_command.replace("underline", "textnormal")
|
||||||
.replace("underline", "textnormal")
|
|
||||||
)
|
|
||||||
result = result.replace(nested_command, new_command)
|
result = result.replace(nested_command, new_command)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -860,7 +856,14 @@ def copy_theme_files_to_output_directory(
|
||||||
|
|
||||||
for theme_file in theme_directory_path.iterdir():
|
for theme_file in theme_directory_path.iterdir():
|
||||||
dont_copy_files_with_these_extensions = [".j2.tex", ".py"]
|
dont_copy_files_with_these_extensions = [".j2.tex", ".py"]
|
||||||
if theme_file.suffix not in dont_copy_files_with_these_extensions:
|
# theme_file.suffix returns the latest part of the file name after the last dot.
|
||||||
|
# But we need the latest part of the file name after the first dot:
|
||||||
|
try:
|
||||||
|
suffix = re.search(r"\..*", theme_file.name)[0]
|
||||||
|
except TypeError:
|
||||||
|
suffix = ""
|
||||||
|
|
||||||
|
if suffix not in dont_copy_files_with_these_extensions:
|
||||||
if theme_file.is_dir():
|
if theme_file.is_dir():
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
str(theme_file),
|
str(theme_file),
|
||||||
|
|
Loading…
Reference in New Issue