#!/usr/bin/env python3
"""
Test script for page creation functionality
Creates a sample HTML page from Markdown to verify the conversion works
"""

import sys
sys.path.append('/Users/neog')
from markdown_converter import generate_html_page
from datetime import datetime

# Sample Markdown content
sample_markdown = """# NEOG System Status

## Overview

This is a **test page** created to demonstrate the Markdown to HTML conversion.

### System Components

| Component | Status | Details |
|-----------|--------|---------|
| Log Server | ✅ Active | Running on port 9001 |
| Terminal | ✅ Running | Web-based shell |
| AI Integration | ✅ Connected | LM Studio |
| Dashboard | ✅ Live | Real-time logs |

### Features Implemented

- **Multi-line Markdown** support
- *Styled* HTML output with NEOG theme
- `Code formatting` inline and blocks
- Tables with proper formatting
- Links and references

```python
# Example code block
def create_page(content):
    html = markdown_to_html(content)
    return generate_html_page(html)
```

> This is a blockquote to demonstrate styling

### Commands Available

1. `create-page` - Create HTML page from Markdown
2. `list-pages` - List all created pages
3. `open-page` - Open specific page

---

**Test completed successfully!** ✅

[View Dashboard](http://localhost:9001/dashboard) | [Metrics](http://localhost:9001/metrics)
"""

# Generate HTML
timestamp = datetime.now().strftime('%Y-%m-%d-%H%M%S')
filename = f'test-page-{timestamp}.html'
filepath = f'/Users/neog/pages/{filename}'

html = generate_html_page(sample_markdown, "NEOG System Status - Test Page")

# Save file
with open(filepath, 'w') as f:
    f.write(html)

print(f"✅ Test page created successfully!")
print(f"📄 Filename: {filename}")
print(f"💾 Path: {filepath}")
print(f"🔗 Size: {len(html)} bytes")
print(f"\n📂 To view: open {filepath}")
print(f"🌐 Or visit: http://localhost:9001/page/{filename}")
