5
0
Fork 0

Merge branch 'pandocErweiterung' of https://git.famhahn.xyz/nick/hedgedoc2pdf into pandocErweiterung

This commit is contained in:
m.haas 2023-06-13 12:25:45 +02:00
commit b3570862ec

View file

@ -5,6 +5,7 @@ editor=$USER
title= title=
file= file=
ending=tex ending=tex
toc=false
# path to this script # path to this script
script=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) script=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
@ -15,13 +16,14 @@ echo Usage: pandocPipeline [OPTION] [COMMAND]
echo -h, --help show this help screen echo -h, --help show this help screen
echo -f, --file specify filename without extension echo -f, --file specify filename without extension
echo -e, --ending spefify target file format echo -e, --ending spefify target file format
echo -u, --user=editor enter name of file editor set between "" \(only for target format pdf\) echo -u, --user=$editor enter name of file editor set between "" \(only for target format pdf\)
echo -t, --title enter title of document set between "" \(only for target format pdf\) echo -t, --title enter title of document set between "" \(only for target format pdf\)
echo -c --toc prints a table of content at the start of the document
echo Pipeline is optimized for target format pdf and docx but works with others as well 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 Possible fileformats see: https://pandoc.org/diagram.svgz?v=20230203095535
echo Examples: echo Examples:
echo md -> pdf : pandocPipeline -u "Dokumentbearbeiter" -t "Dokumententitel" -f dateiname -e pdf echo md -\> pdf : pandocPipeline -u "Dokumentbearbeiter" -t "Dokumententitel" -f dateiname -e pdf
echo md -> docx : pandocPipeline -f dateiname -e docx echo md -\> docx : pandocPipeline -f dateiname -e docx
} }
Errorfile() { Errorfile() {
@ -38,8 +40,6 @@ Open() {
POSITIONAL_ARGS=() POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
echo $1
echo $2
case $1 in case $1 in
-u|--user) -u|--user)
editor="$2" editor="$2"
@ -56,6 +56,9 @@ while [[ $# -gt 0 ]]; do
-v|--version) -v|--version)
echo pandocPipeline $version echo pandocPipeline $version
exit;; exit;;
-c|--toc)
toc=true
shift;;
-h|--help) -h|--help)
Help Help
exit;; exit;;
@ -69,18 +72,16 @@ if [[ -z "$file" ]]; then
exit exit
elif [[ "$ending" == "pdf" ]]; then elif [[ "$ending" == "pdf" ]]; then
header=$script/header.md header=$script/header.md
echo $header
sedfile=$script/body.sed sedfile=$script/body.sed
echo $sedfile
picture=$script/Logo.png picture=$script/Logo.png
echo $picture
sed -i 's,Editor:.*,Editor: '"$editor"' \\\\,' $header sed -i 's,Editor:.*,Editor: '"$editor"' \\\\,' $header
echo 1
sed -i 's,Title:.*,Title: '"$title"',' $header sed -i 's,Title:.*,Title: '"$title"',' $header
echo 2
sed -i 's,textwidth]{.*,textwidth]{'"$picture"'}},' $header sed -i 's,textwidth]{.*,textwidth]{'"$picture"'}},' $header
echo 3 if "$toc"; then
cat $file.md $header | sed -E -f $sedfile| pandoc --filter pandoc-latex-environment --number-sections --toc -i - -o $file.pdf cat $file.md $header | sed -E -f $sedfile| pandoc --filter pandoc-latex-environment --number-sections --toc -i - -o $file.pdf
else
cat $file.md $header | sed -E -f $sedfile| pandoc --filter pandoc-latex-environment --number-sections -i - -o $file.pdf
fi
Open Open
elif [[ "$ending" == "docx" ]]; then elif [[ "$ending" == "docx" ]]; then
refdoc=$script/custom-reference.docx refdoc=$script/custom-reference.docx
@ -89,4 +90,4 @@ elif [[ "$ending" == "docx" ]]; then
else else
pandoc $file.md -f markdown -t $ending -s -o $file.$ending pandoc $file.md -f markdown -t $ending -s -o $file.$ending
Open Open
fi fi