5
0
Fork 0

reduce to only pandoc pipeline + fix script according to downstream patches

This commit is contained in:
kleines Filmröllchen 2026-02-07 22:11:04 +01:00
parent 5660ac2021
commit 028ae6b26f
Signed by: filmroellchen
SSH key fingerprint: SHA256:NarU6J/XgCfEae4rbei0YIdN2pYaYDccarK6R53dnc8
19 changed files with 54 additions and 231 deletions

124
pandocPipeline.bat Normal file
View file

@ -0,0 +1,124 @@
@echo off
::if no arguments given show help
IF "%1"=="" (goto :help)
set editor=%USERNAME%
set title =
set file = none
set ending = tex
set "_="
::path to this script
set script= %~dp0
set version= 1.0
::parsing arguments
:loop
IF NOT "%1"=="" (
IF "%1"=="-h" (
goto :help
)
IF "%1"=="--help" (
goto :help
)
IF "%1"=="-v" (
goto :version
)
IF "%1"=="--version" (
goto :version
)
IF "%1"=="-f" (
SET file=%2
SHIFT
)
IF "%1"=="--file" (
SET file=%2
SHIFT
)
IF "%1"=="-e" (
SET ending=%2
SHIFT
)
IF "%1"=="--ending" (
SET ending=%2
SHIFT
)
SHIFT
GOTO :loop
)
:program
::check if file to parse was given
IF %file%==none (goto :errorfile) ELSE (goto :extract_metadata)
:extract_metadata
set title=%file%
For /F "UseBackQ Tokens=1,*" %%G In ("%file%.md") Do (
If "%%~G" == "title:" (
set title=%%H
)
If "%%~G" == "author:" (
set editor=%%H
)
)
goto :selection
:selection
IF %ending%==pdf (goto :program_tex)
IF %ending%==docx (goto :program_docx) ELSE (goto :program_other)
:program_tex
set header=%script%header.md
set header=%header: =%
set sedfile=%script%body.sed
set sedfile=%sedfile: =%
set picture=%script%Logo.png
set picture=%picture: =%
set picture=%picture:\=/%
set pandocenv=%script%pandoc_latex_environment.py
set pandocenv=%pandocenv: =%
::fill header with appropriate information
sed -i 's,Editor:.*,Editor: '"%editor%"' \\\\\\\\,' %header%
sed -i 's,Title:.*,Title: '"%title%"',' %header%
sed -i 's,textwidth]{.*,textwidth]{'%picture%'}},' %header%
::execute pandoc
cat %file%.md %header% | sed -E -f %sedfile%| pandoc --filter %pandocenv% --number-sections --toc -i - -o %file%.pdf
goto :open
:program_docx
set refdoc=%script%custom-reference.docx
set refdoc=%refdoc: =%
pandoc %file%.md --reference-doc=%refdoc% -f markdown -t %ending% -s -o %file%.%ending%
goto :open
:program_other
pandoc %file%.md -f markdown -t %ending% -s -o %file%.%ending%
goto :open
:open
%file%.%ending%
goto :end
:help
echo Tool to convert file from markdown to another format
echo Usage: pandocPipeline [OPTION] [COMMAND]
echo -h, --help show this help screen
echo -f, --file specify filename without extension
echo -e, --ending spefify target file format
echo Pipeline is optimized for target format pdf and docx but works with others as well
echo Possible fileformats see: https://pandoc.org/diagram.svgz?v=20230203095535
echo Author is by default %USERNAME% to change the author add the author to the metadata in your markdown file
echo Title is by default the filename to change the title add the title to the metadata in your markdown file
goto :end
:version
echo pandocPipeline %version%
goto :end
:errorfile
echo No file was given
echo Please add a filename to your command
echo Try 'pandocPipeline --help' for more information
goto :end
:end