Commit c0695e8c authored by Sabina Köfler's avatar Sabina Köfler
Browse files

Add sed search for TOC removal

parent 6cc79d0d
Pipeline #1124 passed with stage
in 2 minutes and 35 seconds
......@@ -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 "\nBeginning 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 "\nExisting 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 "\nAll files complete!"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment