Pandoc – convert Markdown to HTML

And much more…

https://github.com/jgm/pandoc/releases/latest

https://pandoc.org/MANUAL.html

For fast single-page conversion use the inline-browser tool StackEdit:
https://stackedit.io/app#

Example:

pandoc -f markdown -t html -o .\output.html -M mainfont:sans-serif -M maxwidth:72em --standalone .\input.md

And with a powershell script for converting an entire folder:

param(
    [Parameter(Position = 0)]
    [string]$Path,

    [switch]$Recurse
)

$ErrorActionPreference = 'Stop'

# Fallback to current directory when no path is provided.
if ([string]::IsNullOrWhiteSpace($Path)) {
    $TargetPath = (Get-Location).Path
}
else {
    $TargetPath = (Resolve-Path -Path $Path).Path
}

if (-not (Test-Path -Path $TargetPath -PathType Container)) {
    throw "Target path is not a directory: $TargetPath"
}

$pandocCommand = Get-Command pandoc -ErrorAction SilentlyContinue
if ($null -eq $pandocCommand) {
    throw "pandoc is not available in PATH. Install pandoc first and try again."
}

$searchParams = @{
    Path   = $TargetPath
    Filter = '*.md'
    File   = $true
}

if ($Recurse) {
    $searchParams.Recurse = $true
}

$markdownFiles = Get-ChildItem @searchParams | Sort-Object FullName

if ($markdownFiles.Count -eq 0) {
    Write-Host "No markdown files found in: $TargetPath"
    exit 0
}

Write-Host "Found $($markdownFiles.Count) markdown file(s) in: $TargetPath"

foreach ($mdFile in $markdownFiles) {
    $htmlPath = [System.IO.Path]::ChangeExtension($mdFile.FullName, '.html')

    Write-Host "Converting: $($mdFile.FullName)"

    $pandocArgs = @(
        '-f', 'markdown',
        '-t', 'html',
        '-o', $htmlPath,
        '-M', 'mainfont:sans-serif',
        '-M', 'maxwidth:72em',
        '--standalone',
        $mdFile.FullName
    )

    & pandoc @pandocArgs

    if ($LASTEXITCODE -ne 0) {
        throw "pandoc failed for file: $($mdFile.FullName)"
    }
}

Write-Host "Done. Converted $($markdownFiles.Count) markdown file(s) to HTML."
101410cookie-checkPandoc – convert Markdown to HTML