-
-
Save diev/28f3f1d0b5cc6aa0f8f52dfbeadb2f0c to your computer and use it in GitHub Desktop.
Use the GitHub markdown service to convert md to html via powershell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] Param ( | |
| [Parameter(Position = 0, Mandatory = $True, ValueFromPipelineByPropertyName = $True)] | |
| [ValidateNotNullOrEmpty()] | |
| [Alias('FullName')] | |
| [String] | |
| $filePath | |
| ) | |
| function ConvertFrom-md($mdText){ | |
| $response = Invoke-WebRequest -Uri 'https://api.github.com/markdown/raw' -Method Post -body "$mdText" -ContentType "text/plain" | |
| return $response.Content | |
| } | |
| #get the full path | |
| $fullPath = Resolve-Path $filePath | |
| #Get Text | |
| $mdt = [String]::Join([environment]::NewLine, (Get-Content $fullPath)); #Get-Content loses linebreaks for some reason. | |
| #Convert And Save to a temp file (warning, will overwrite) | |
| (ConvertFrom-md $mdt) | Out-File $env:TEMP\markdown.html | |
| #Launch in browser | |
| & start iexplore $env:temp\markdown.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment