|
|
| $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
|
|
|
|
|
| try {
|
| $word = New-Object -ComObject Word.Application
|
| $word.Visible = $false
|
| $doc = $word.Documents.Add()
|
| $selection = $word.Selection
|
|
|
|
|
| $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 "^---") {
|
|
|
|
|
| } elseif ($line -match "^\|") {
|
|
|
| $selection.Style = "Normal"
|
| $selection.TypeText($line)
|
| $selection.TypeParagraph()
|
| } else {
|
| $selection.Style = "Normal"
|
|
|
| $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() }
|
| }
|
|
|