new_blog/projects/gen-html.sh
2025-07-10 16:31:43 -04:00

30 lines
620 B
Bash
Executable file

#!/bin/bash
# Exit if any command fails
set -eu
# Output file
OUTPUT="combined.html"
# Clear previous output if exists
> "$OUTPUT"
# Loop through all Markdown files in the current directory
for file in *.md; do
if [[ -f "$file" ]]; then
echo "Processing $file..."
# Convert Markdown to HTML using pandoc
html_content=$(pandoc "$file")
# Wrap the content in a <section> tag and append to output
{
echo "<section>"
echo "$html_content"
echo "</section>"
} >> "$OUTPUT"
fi
done
echo "Done. Output saved to $OUTPUT"