@@ -0,0 +1,35 @@
|
||||
# Build PDF from markdown via two pipelines:
|
||||
# 1) MD → LaTeX project (Python md2latex)
|
||||
# 2) LaTeX → PDF (XeLaTeX / latexmk)
|
||||
#
|
||||
# Usage:
|
||||
# powershell -File scripts\md2pdf.ps1 examples\example.md
|
||||
# powershell -File scripts\md2pdf.ps1 report.md -OutDir build\report -TitlePage title.pdf
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0)]
|
||||
[string]$Markdown,
|
||||
|
||||
[string]$OutDir = "",
|
||||
|
||||
[string]$TitlePage = "",
|
||||
|
||||
[switch]$NoPdf
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
Set-Location $Root
|
||||
|
||||
$md = Resolve-Path $Markdown
|
||||
if (-not $OutDir) {
|
||||
$OutDir = Join-Path (Split-Path $md) (([IO.Path]::GetFileNameWithoutExtension($md)) + "_latex")
|
||||
}
|
||||
|
||||
$pyArgs = @("-m", "md2latex", "$md", "-o", "$OutDir")
|
||||
if ($TitlePage) { $pyArgs += @("--titlepage", "$TitlePage") }
|
||||
if (-not $NoPdf) { $pyArgs += "--pdf" }
|
||||
|
||||
Write-Host "=== Pipeline 1+2: MD → LaTeX → PDF ==="
|
||||
& python @pyArgs
|
||||
exit $LASTEXITCODE
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# MD → LaTeX → PDF (XeLaTeX)
|
||||
# Usage: scripts/md2pdf.sh report.md [out_dir]
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
MD="${1:?markdown file}"
|
||||
OUT="${2:-}"
|
||||
ARGS=(-m md2latex "$MD" --pdf)
|
||||
if [[ -n "$OUT" ]]; then ARGS+=(-o "$OUT"); fi
|
||||
exec python "${ARGS[@]}"
|
||||
Reference in New Issue
Block a user