43 lines
1.2 KiB
PowerShell
43 lines
1.2 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $false, Position = 0)]
|
|
[string]$RelativePath = ".",
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
[switch]$Recurse
|
|
)
|
|
|
|
$scriptDir = $PSScriptRoot
|
|
$cfgFile = Join-Path $scriptDir 'mermaid-config.json'
|
|
|
|
$targetDir = Join-Path $scriptDir $RelativePath
|
|
|
|
if (-not (Test-Path $targetDir)) {
|
|
Write-Error "Der Zielordner '$targetDir' existiert nicht."
|
|
exit 1
|
|
}
|
|
|
|
$mmdFiles = Get-ChildItem -Path $targetDir -Filter '*.mmd' -Recurse:$Recurse
|
|
|
|
if ($mmdFiles.Count -eq 0) {
|
|
Write-Host "Keine .mmd-Dateien in '$targetDir' gefunden." -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "Verarbeite Ordner: $targetDir (Rekursiv: $Recurse)" -ForegroundColor Yellow
|
|
|
|
foreach ($file in $mmdFiles) {
|
|
Write-Host "Konvertiere $($file.Name) ($($file.DirectoryName))..." -ForegroundColor Cyan
|
|
|
|
$destSvg = Join-Path $file.DirectoryName "$($file.BaseName).svg"
|
|
$destPng = Join-Path $file.DirectoryName "$($file.BaseName).png"
|
|
|
|
if (Test-Path $cfgFile) {
|
|
mmdc -i $file.FullName -o $destSvg -c $cfgFile
|
|
} else {
|
|
mmdc -i $file.FullName -o $destSvg
|
|
}
|
|
|
|
mmdc -i $file.FullName -o $destPng -s 3
|
|
}
|
|
|
|
Write-Host "Fertig! Alle Diagramme wurden konvertiert." -ForegroundColor Green |