#!/usr/bin/env python3 """ Inject inline style tag into all HTML files to force 12pt font """ import os import re from pathlib import Path def inject_style_tag(file_path): """Add style tag after to force 12pt.""" try: with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() original_content = content # Check if our style tag already exists if '/* FORCE ALL FONTS TO 12PT */' in content: return False # Inject style tag after or style_injection = ''' ''' # Try to inject after content = re.sub(r'(]*>)', r'\1\n' + style_injection, content, flags=re.IGNORECASE) if content != original_content: with open(file_path, 'w', encoding='utf-8', errors='ignore') as f: f.write(content) return True return False except Exception as e: print(f"Error processing {file_path}: {e}") return False def main(): base_dir = Path('/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help') if not base_dir.exists(): print(f"Error: Directory {base_dir} not found") return # Find all .htm files htm_files = list(base_dir.rglob('*.htm')) print(f"Found {len(htm_files)} HTML files") print("Injecting inline style tags...") modified_count = 0 for htm_file in htm_files: if inject_style_tag(htm_file): modified_count += 1 if modified_count % 100 == 0: print(f" Processed {modified_count} files...") print(f"\nComplete! Modified {modified_count} files") print("All files now have inline style tags forcing 12pt font.") if __name__ == "__main__": main()