#!/usr/bin/env python3 """ Convert Markdown to styled HTML that can be printed to PDF from browser """ import markdown import os def convert_md_to_html(input_file, output_file): """Convert markdown file to HTML""" # Read markdown file with open(input_file, 'r', encoding='utf-8') as f: md_content = f.read() # Convert markdown to HTML html = markdown.markdown(md_content, extensions=['tables', 'fenced_code', 'codehilite']) # Add CSS styling html_with_style = f""" Freelance Dashboard - Technical Reference {html} """ # Save HTML with open(output_file, 'w', encoding='utf-8') as f: f.write(html_with_style) print(f"HTML created successfully: {output_file}") print(f"\nTo create PDF:") print(f"1. Open the HTML file in your browser") print(f"2. Click 'Print to PDF' button or use Ctrl+P") print(f"3. Select 'Save as PDF' as destination") print(f"4. Save the file") if __name__ == '__main__': input_file = r'C:\Users\alexi\Documents\projects\freelance-dashboard\TECHNICAL_REFERENCE_EN.md' output_file = r'C:\Users\alexi\Documents\projects\freelance-dashboard\TECHNICAL_REFERENCE_EN.html' if os.path.exists(input_file): convert_md_to_html(input_file, output_file) # Open in default browser import webbrowser webbrowser.open(f'file:///{output_file}') else: print(f"Input file not found: {input_file}")