Spaces:
Running
Running
''' | |
the issue is about $ here comes somezhting eq1 termsi whitespace $ | |
the whitespace must be removed for proper displaying | |
go through all qdms files and find the white spaces at the beginning and | |
at the end | |
''' | |
import pathlib | |
import re | |
# get current working directory | |
cwd = pathlib.Path().cwd() | |
# define output path | |
inp_Fold = cwd / "Data/1_Writing/" | |
# pat = r"\\$[^\\$]+\\$" | |
pat = r"\$[^\$]+\$" | |
pat_Start = r"(\s)\$" | |
pat_End = r"\$(\s)" | |
found_And_Replace= {} | |
# recursively looking into all folders --> subfolders are looked into as well | |
for iF,ct_File in enumerate(inp_Fold.rglob('*.qmd')): | |
# print(ct_File.name) | |
file_Content = [] | |
with open(str(ct_File),"r") as file: | |
file_Content = file.readlines() | |
for il, line in enumerate(file_Content): | |
results = re.findall(pat, line) | |
# found all simmilar to ['$\\beta_i$'] --> make sure that start and end with empty space are both covered | |
for je, elem in enumerate(results): | |
# start with empty space | |
res_Start = re.findall(pat_Start, elem) | |
res_End = re.findall(pat_End, elem) | |
if len(res_Start) > 0 or len(res_End): | |
# print(f"found results in file: {ct_File}") | |
print(f"elem: {elem}") | |
print("done") |