Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tissue Research JKU
Tissue Research Doc
Commits
c0695e8c
Commit
c0695e8c
authored
Nov 30, 2021
by
Sabina Köfler
Browse files
Add sed search for TOC removal
parent
6cc79d0d
Pipeline
#1124
passed with stage
in 2 minutes and 35 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
quick-start-guides/convert_to_pdf.sh
View file @
c0695e8c
...
...
@@ -6,6 +6,8 @@ replace_whitespaces() {
mv
"
$f
"
"
${
f
// /_
}
"
;
done
}
# Create array to store all md files for later
# readarray -d '' array < <(find . -iname "*.md" -o -iname "*.mdown" -o -iname "*.markdown")
create_filearray
()
{
...
...
@@ -56,7 +58,7 @@ extract_filename() {
y
=
"
$file
"
# ./FILENAME.EXTENSION
x
=
"
${
y
%.*
}
"
# ./FILENAME
z
=
"
${
x
##*/
}
"
# FILENAME
echo
"Extracted filename:
${
z
}
"
#
echo "Extracted filename: ${z}"
}
create_date_string
()
{
...
...
@@ -94,23 +96,31 @@ select_latex_engine
# Compile documents
echo
-e
"
\n
Beginning conversion...
\n
"
search
=
"
\[\[
_TOC_
\]\]
"
# find . -iname "*.md" -o -iname "*.mdown" -o -iname "*.markdown" | while read -r file; do # find -iname finds <pattern> case insensitive
for
file
in
"
${
files
[@]
}
"
;
do
echo
"File:"
${
file
}
#
echo "File:" ${file}
extract_filename
construct_pdf_path
construct_bak_pdf_path
echo
"PDF Path:
$pdf_path
"
#
echo "PDF Path: $pdf_path"
if
[
-f
"
$pdf_path
"
]
;
then
echo
"File
$file
was already converted."
#
echo "File $file was already converted."
create_date_string
echo
"Bak file name:
$bak_pdf_filename
"
#
echo "Bak file name: $bak_pdf_filename"
mv
$pdf_path
$bak_pdf_path
echo
-e
"
\n
Existing file was moved to
${
bak_pdf_path
}
\n
"
fi
echo
-e
"Continuing with new file creation
\n
"
pandoc
-s
--toc
--template
=
my.latex
-f
gfm
"
$file
"
--pdf-engine
=
$option
-o
"
$pdf_path
"
# could add --variable font-family:sans-serif $variable
echo
-e
"File created
\n
"
# remove the line that renders the table of contents in markdown
if
[
"
$search
"
]
;
then
# TODO - should files be copied if search string is found?
echo
"Nothing to replace"
else
echo
"I am replacing"
# sed -i "/$search/d" $file
fi
# echo -e "Continuing with new file creation\n"
# pandoc -s --toc --template=my.latex -f gfm "$file" --pdf-engine=$option -o "$pdf_path" # could add --variable font-family:sans-serif $variable
# echo -e "File created\n"
done
echo
-e
"
\n
All files complete!"
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment