--- id: aliases: [] tags: [] title: Converting Documents to Markdown --- # Converting Documents to Markdown ```powershell param( [string]$Path ) $content = Get-Content -Path $Path $newContent = $content $newContent -replace "foos", "ball" $newContent -replace "foo", "bar" # ... Set-Content -Path $Path -Value $newContent ``` ## Converting NFPA Code ```powershell # "210.17(B)(3)" -> h5 $newContent -replace '^(\d{3}\.\d+\([A-Z]\)\(\d\) .+)$', '\n##### $1\n' # "210.17(B)" -> h4 $newContent -replace '^(\d{3}\.\d+\([A-Z]\) .+)$', '\n#### $1\n' # "210.17" -> h3 $newContent -replace '^(\d{3}\.\d+ .+)$', '\n### $1\n' # "(1)" -> "1." $newContent -replace '^\((\d)\)', '$1\.' ``` ## Semantic Line Breaks [[semantic-line-breaks]]