From d956fe8d840daa5f26032845b8733079db216ac0 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Thu, 21 Mar 2024 18:58:14 +0100 Subject: [PATCH] renderer: allow users to make bold or italic text normal (#45) --- rendercv/renderer.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rendercv/renderer.py b/rendercv/renderer.py index fc24f63..952df1e 100644 --- a/rendercv/renderer.py +++ b/rendercv/renderer.py @@ -180,6 +180,22 @@ class LaTeXFile(TemplatedFile): section_title, is_first_entry, ) + + # If there is nested \textbf, \textit, or \underline commands, replace the inner + # ones with \textnormal: + + # Find all the nested commands: + nested_commands = re.findall(r"\\textbf{.*?(\\textbf{.*?})", result) + nested_commands += re.findall(r"\\textit{.*?(\\textit{.*?})", result) + nested_commands += re.findall(r"\\underline{.*?(\\underline{.*?})", result) + + # Replace the inner commands with \textnormal: + for nested_command in nested_commands: + new_command = nested_command.replace("textbf", "textnormal") + new_command = new_command.replace("textit", "textnormal") + new_command = new_command.replace("underline", "textnormal") + result = result.replace(nested_command, new_command) + return result def get_latex_code(self):