diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-04-24 15:22:41 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-04-24 15:22:41 -0600 |
| commit | 7e0b4501030aa268da323c1eaa69c8a2b29ee6a3 (patch) | |
| tree | 91561278b0b74bfc5cd986f043d63b0c2fd1e534 /book/generate_tex_files.sh | |
| parent | bb450e5566d16b642236f8c337e74a7f94124599 (diff) | |
Added scripts to generate tex files from markdown
Diffstat (limited to 'book/generate_tex_files.sh')
| -rwxr-xr-x | book/generate_tex_files.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/book/generate_tex_files.sh b/book/generate_tex_files.sh new file mode 100755 index 0000000..87238f4 --- /dev/null +++ b/book/generate_tex_files.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +markdown_dir="../tutorials" +book_dir="." + +# Enable recursive globbing with ** +shopt -s globstar + +# Loop through markdown files in source directory +for filepath in "$markdown_dir"/module_*/**/*.md; do + [ -e "$filepath" ] || continue + + # Get module name and clean it (remove underscore) + module_base=$(basename "$(dirname "$filepath")") # module_# + module_clean="${module_base//_/}" # module# + + # Get filename without extension + filename="${filepath##*/}" # file.md + filename_no_ext="${filename%.md}" # file + + # Make sure output directory exists + output_dir="$book_dir/$module_clean" + mkdir -p "$output_dir" + + # Define output .tex file path + output_file="$output_dir/$filename_no_ext.tex" + + # Convert markdown to LaTeX + pandoc -f markdown -t latex "$filepath" -o "$output_file" + + echo "Converted $filepath -> $output_file" +done |
