Initial commit of akmon project
This commit is contained in:
45
md2pdf_mermaid.bat
Normal file
45
md2pdf_mermaid.bat
Normal file
@@ -0,0 +1,45 @@
|
||||
@echo off
|
||||
REM Markdown to PDF with Mermaid support using pre-rendering
|
||||
REM Usage: md2pdf_mermaid.bat input.md output.pdf
|
||||
|
||||
if "%~2"=="" (
|
||||
echo Usage: %0 input.md output.pdf
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set INPUT=%~1
|
||||
set OUTPUT=%~2
|
||||
|
||||
echo Converting %INPUT% to %OUTPUT% with Mermaid pre-rendering...
|
||||
|
||||
REM Create temporary directory for processed files
|
||||
set TEMP_DIR=%TEMP%\mermaid_temp_%RANDOM%
|
||||
mkdir "%TEMP_DIR%"
|
||||
|
||||
REM Copy input file to temp directory
|
||||
copy "%INPUT%" "%TEMP_DIR%\input.md"
|
||||
|
||||
REM Change to temp directory and process
|
||||
cd /d "%TEMP_DIR%"
|
||||
|
||||
REM Use mermaid-filter to pre-process the markdown
|
||||
pandoc "input.md" --filter mermaid-filter -t markdown -o "processed.md"
|
||||
|
||||
REM Convert to PDF using pandoc
|
||||
pandoc "processed.md" -o "%OUTPUT%"
|
||||
|
||||
REM Copy output back to original directory
|
||||
if exist "%OUTPUT%" (
|
||||
copy "%OUTPUT%" "%~dp0%OUTPUT%"
|
||||
)
|
||||
|
||||
REM Clean up
|
||||
cd /d "%~dp0"
|
||||
rmdir /s /q "%TEMP_DIR%"
|
||||
|
||||
if %errorlevel% equ 0 (
|
||||
echo Conversion completed successfully!
|
||||
) else (
|
||||
echo Conversion failed!
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
Reference in New Issue
Block a user