blob: 87238f4fd7207f26ec4f00a23eab7dab8aaf68b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|