$markdownPath = "C:\Users\hp\.gemini\antigravity\brain\04f3e1c4-7b81-497c-a7c5-5d0513033dfa\project_report.md" $wordPath = "C:\Users\hp\.gemini\antigravity\brain\04f3e1c4-7b81-497c-a7c5-5d0513033dfa\VoiceVerse_AI_Project_Report.docx" if (-not (Test-Path $markdownPath)) { Write-Error "Markdown file not found at $markdownPath" exit 1 } $content = Get-Content -Path $markdownPath -Raw # Create Word Object try { $word = New-Object -ComObject Word.Application $word.Visible = $false $doc = $word.Documents.Add() $selection = $word.Selection # Basic Markdown Parsing (Simplified) $lines = $content -split "`r?`n" foreach ($line in $lines) { if ($line -match "^# (.*)") { $selection.Style = "Title" $selection.TypeText($matches[1]) $selection.TypeParagraph() } elseif ($line -match "^## (.*)") { $selection.Style = "Heading 1" $selection.TypeText($matches[1]) $selection.TypeParagraph() } elseif ($line -match "^### (.*)") { $selection.Style = "Heading 2" $selection.TypeText($matches[1]) $selection.TypeParagraph() } elseif ($line -match "^---") { # Skip horizontal rules or add a page break? # For now just skip } elseif ($line -match "^\|") { # Table handling is complex, for now just TypeText $selection.Style = "Normal" $selection.TypeText($line) $selection.TypeParagraph() } else { $selection.Style = "Normal" # Remove bold/italic markers for cleaner look $cleanLine = $line -replace "\*\*", "" -replace "\*", "" $selection.TypeText($cleanLine) $selection.TypeParagraph() } } $doc.SaveAs([ref]$wordPath) $doc.Close() $word.Quit() Write-Host "Word document created successfully at $wordPath" } catch { Write-Error "Failed to create Word document: $_" if ($word) { $word.Quit() } }