From 23c4c61013b007d63c50843155f11d42441d6333 Mon Sep 17 00:00:00 2001
From: Sebastian Kawelke <kawelkesebastian@gmail.com>
Date: Tue, 10 Dec 2024 17:32:31 +0100
Subject: [PATCH] Workaround for footnote handling with activiated highlighting

Signed-off-by: Sebastian Kawelke <kawelkesebastian@gmail.com>
---
 scripts/preprocessors/latex_preprocessor.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/scripts/preprocessors/latex_preprocessor.py b/scripts/preprocessors/latex_preprocessor.py
index 01f9adf..2a9e92a 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,"
-- 
GitLab