Tags: code
To concatenate multiple Markdown (.md) files into a single index.html, you can use Pandoc. This Bash script automates the generation of an index.html file from a set of Markdown files, using Pandoc for conversion.
Step-by-step Explanation
- Variable Setup
OUTFILE: Output HTML file (index.html)
BIB_FILE, CSL_FILE, TEMPLATE: Files for bibliography, citation style, and HTML template - Check for Updates
Gets the last modified time of index.html (or sets to 0 if it doesnβt exist).
Finds all Markdown files matching the pattern YYYY-MM-DD-*.md that are newer than index.html. - Early Exit
If no Markdown files are newer than index.html, the script exits early to avoid unnecessary work. - HTML Header
Writes a standard HTML header to index.html. - Markdown Conversion
Loops through all Markdown files (newest first, for consistency).
Uses Pandoc to convert each Markdown file to HTML, applying the template, bibliography, and citation style.
Appends the converted HTML to index.html. - HTML Footer
Adds a closing