Extract header information from md
This commit is contained in:
parent
df5864e593
commit
494e9aa984
1 changed files with 25 additions and 21 deletions
|
|
@ -7,6 +7,7 @@ set editor=%USERNAME%
|
||||||
set title =
|
set title =
|
||||||
set file = none
|
set file = none
|
||||||
set ending = tex
|
set ending = tex
|
||||||
|
set "_="
|
||||||
::path to this script
|
::path to this script
|
||||||
set script= %~dp0
|
set script= %~dp0
|
||||||
set version= 1.0
|
set version= 1.0
|
||||||
|
|
@ -26,22 +27,6 @@ IF NOT "%1"=="" (
|
||||||
IF "%1"=="--version" (
|
IF "%1"=="--version" (
|
||||||
goto :version
|
goto :version
|
||||||
)
|
)
|
||||||
IF "%1"=="-u" (
|
|
||||||
SET editor=%2
|
|
||||||
SHIFT
|
|
||||||
)
|
|
||||||
IF "%1"=="-user" (
|
|
||||||
SET editor=%2
|
|
||||||
SHIFT
|
|
||||||
)
|
|
||||||
IF "%1"=="-t" (
|
|
||||||
SET title=%2
|
|
||||||
SHIFT
|
|
||||||
)
|
|
||||||
IF "%1"=="--title" (
|
|
||||||
SET title=%2
|
|
||||||
SHIFT
|
|
||||||
)
|
|
||||||
IF "%1"=="-f" (
|
IF "%1"=="-f" (
|
||||||
SET file=%2
|
SET file=%2
|
||||||
SHIFT
|
SHIFT
|
||||||
|
|
@ -64,8 +49,23 @@ IF NOT "%1"=="" (
|
||||||
|
|
||||||
:program
|
:program
|
||||||
::check if file to parse was given
|
::check if file to parse was given
|
||||||
IF %file%==none (goto :errorfile)
|
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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
set title=%title:~3,-1%
|
||||||
|
set editor=%editor:~3,-1%
|
||||||
|
goto :selection
|
||||||
|
|
||||||
|
:selection
|
||||||
IF %ending%==pdf (goto :program_tex)
|
IF %ending%==pdf (goto :program_tex)
|
||||||
IF %ending%==docx (goto :program_docx) ELSE (goto :program_other)
|
IF %ending%==docx (goto :program_docx) ELSE (goto :program_other)
|
||||||
|
|
||||||
|
|
@ -80,8 +80,8 @@ set picture=%picture:\=/%
|
||||||
set pandocenv=%script%pandoc_latex_environment.py
|
set pandocenv=%script%pandoc_latex_environment.py
|
||||||
set pandocenv=%pandocenv: =%
|
set pandocenv=%pandocenv: =%
|
||||||
::fill header with appropriate information
|
::fill header with appropriate information
|
||||||
sed -i 's,Editor:.*,Editor: '%editor%' \\\\\\\\,' %header%
|
sed -i 's,Editor:.*,Editor: '"%editor%"' \\\\\\\\,' %header%
|
||||||
sed -i 's,Title:.*,Title: '%title%',' %header%
|
sed -i 's,Title:.*,Title: '"%title%"',' %header%
|
||||||
sed -i 's,textwidth]{.*,textwidth]{'%picture%'}},' %header%
|
sed -i 's,textwidth]{.*,textwidth]{'%picture%'}},' %header%
|
||||||
::execute pandoc
|
::execute pandoc
|
||||||
cat %file%.md %header% | sed -E -f %sedfile%| pandoc --filter %pandocenv% --number-sections --toc -i - -o %file%.pdf
|
cat %file%.md %header% | sed -E -f %sedfile%| pandoc --filter %pandocenv% --number-sections --toc -i - -o %file%.pdf
|
||||||
|
|
@ -107,10 +107,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=%USERNAME% 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 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 Author is by default %USERNAME%
|
||||||
|
echo to change the author write follwing in your markdown file
|
||||||
|
echo [Author]: # (your name)
|
||||||
|
echo Title is by default the filename
|
||||||
|
echo to change the title write follwing in your markdown file
|
||||||
|
echo [Title]: # (document title)
|
||||||
goto :end
|
goto :end
|
||||||
|
|
||||||
:version
|
:version
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue