Skip to content

Instantly share code, notes, and snippets.

@altavir
Last active April 27, 2022 07:48
Show Gist options
  • Save altavir/a9f4f54cfb7d660067a7c7dbbc71e833 to your computer and use it in GitHub Desktop.
Save altavir/a9f4f54cfb7d660067a7c7dbbc71e833 to your computer and use it in GitHub Desktop.
PowerShell + Lua to build report from markdown.
$repoPath = (Get-Item $PSScriptRoot).parent
# Create an output directory
New-Item -Path $repoPath -Name "out" -ItemType "directory"
# Compile markdown to html
Get-ChildItem -Path $repoPath -Recurse -Include *.md | ForEach-Object{
Write-Output $_
$html= $_.directoryname+"/out/" + $_.basename+".html"
$basename = $_.BaseName
pandoc --standalone --mathjax --metadata "title: $basename" -f markdown -t html5 -s $_.name -o $html --lua-filter=misc/links-to-html.lua
}
# Copy images
Copy-Item -Path $repoPath/images -Destination $repoPath/out/images -Recurse
# Rename README.html to index.html
Rename-Item -Path $repoPath/out/README.html -NewName $repoPath/out/index.html
# Compress output into a zip
if(Test-Path $repoPath/report.zip){
Remove-Item -Path $repoPath/report.zip
}
Compress-Archive -Path $repoPath/out -DestinationPath $repoPath/report.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment