diff --git a/scripts/preprocessors/latex_preprocessor.py b/scripts/preprocessors/latex_preprocessor.py index 01f9adf278546a59e2d43d39116c4e1c8d00b7b9..2a9e92ae8b270729b895e53f7edc9fc4fb43afe4 100644 --- a/scripts/preprocessors/latex_preprocessor.py +++ b/scripts/preprocessors/latex_preprocessor.py @@ -28,7 +28,6 @@ def replace_quotes(content: str) -> str: content = content.replace('“', "\\grqq{}") return content - def markdown_style_to_latex_style(content: str) -> str: # translate markdown style bold and italic into latex style # Regex pattern to find *<text>* @@ -54,6 +53,14 @@ def markdown_style_to_latex_style(content: str) -> str: return content +def check_for_footnotes_and_remove_in_addations(content: str) -> str: + # check for footnotes and issue a warning + # remove the footnotes + pattern = r'\[\^.*?\]' + if re.search(pattern, content): + print(f"[WARNING] Footnotes are currently not supported in the additional controls, dependencies, implications and justifications sections. Please remove them. Found: {re.findall(pattern, content)}") + return re.sub(pattern, '', content) + def markdown_enumeration_to_latex_enumeration(content: str) -> str: # translate markdown style enumeration into latex style # Regex pattern to find 1. <text> @@ -131,7 +138,6 @@ def replace_relative_links_with_section_links(file_path: str, content: str) -> s target_content = f.read() # get the markdown title headlines = re.findall(r'(\#\#*) (.*)', target_content) - print(headlines) if len(headlines) == 0: # check if we find a hypertarget with the corresponding link hypertargets = re.findall( @@ -161,7 +167,6 @@ def adjust_links(markdown_files: list): # adjust the links after preprocessing for file_path in markdown_files: with open(file_path, 'r+') as f: - print(f"Adjusting links in {file_path}") content = f.read() content = replace_relative_links_with_section_links( file_path, content) @@ -219,6 +224,8 @@ def modify_additional_controls(content: str): if additional_controls == "": return "" + additional_controls = check_for_footnotes_and_remove_in_addations(additional_controls) + # Define a LaTeX tcolorbox for styling colored_box = ( "\\begin{tcolorbox}[colback=lightgray!100!black,colframe=lightgray!70!black,"