diff --git a/PythonScripts/rust-test-to-html.py b/PythonScripts/rust-test-to-html.py new file mode 100644 index 00000000..534c71ef --- /dev/null +++ b/PythonScripts/rust-test-to-html.py @@ -0,0 +1,61 @@ +import re +import sys +import os + + +def extract_expr_and_fn(file_path): + expr_list = [] + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + + # Use regex to find all function names starting with "fn " and multi-line expressions starting with "expr =" + function_names = re.findall(r'fn\s+(\w+)\s*\(\)', content) + expressions = re.findall(r'expr\s*=\s*"(.*?)"', content, re.DOTALL) + + # Clean up the extracted expressions to remove any extra newlines + expressions = [expr.replace('\n', ' ').strip() for expr in expressions] + + for fn_name, expr in zip(function_names, expressions): + expr_list.append((fn_name, expr)) + + return expr_list + + +def write_to_html(expr_list, output_file): + with open(output_file, 'w', encoding='utf-8') as file: + file.write("
\n") + file.write("