import re

file_path = r"c:\Users\malab\OneDrive\Documents\Projects\nashaajobs-clone\custom_admin\templates\custom_admin\pages\study_abroad\application_detail.html"

with open(file_path, 'r', encoding='utf-8') as f:
    content = f.read()

# Pattern to find Django variable tags split across lines
# Matches {{ followed by anything, including newlines, until }}
pattern = r'(\{\{[^}]+\}\})'

def join_tags(match):
    # Join lines and remove extra spaces
    tag_content = match.group(0)
    if '\n' in tag_content:
        # Replace newlines and surrounding whitespace with a single space
        return re.sub(r'\s*\n\s*', ' ', tag_content)
    return tag_content

# Apply the fix
fixed_content = re.sub(pattern, join_tags, content, flags=re.DOTALL)

with open(file_path, 'w', encoding='utf-8') as f:
    f.write(fixed_content)

print(f"Fixed split tags in {file_path}")
