A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

commit 2233e4d2b213d294892048e4e13637c15c7ac5ad
parent c1714fd09481c7418d3919b2e87d318542c520b1
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Mon, 30 Mar 2020 14:53:59 -0500

Add Pandoc to the squeeze process

Added Pandoc to parse Markdown into HTML and smarted punctuation.
Removed Smartypants.

Mreadme.md | 9+++------
Msqueeze.sh | 9++++++---
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/readme.md b/readme.md @@ -14,7 +14,7 @@ It's pretty closely tailored to my specific needs, but it works, and IMHO it wor * Bash. Used to run the script that automates everything else. * A Prolog interpreter. Tested with [SWI-Prolog](https://www.swi-prolog.org/), but the syntax aims to be vanilla ISO Prolog and should work with any implementation. -* [Smartypants](https://github.com/leohemsted/smartypants.py). Used to smarten the punctuation in the HTML output. +* [Pandoc](http://pandoc.org/). Used to convert Markdown to HTML and smarten the punctuation. ## Assumptions @@ -46,8 +46,4 @@ Generate a static website from Markdown sources: Generate source files from a static website: - ./unsqueeze.sh /home/user/website - -## Still to do - -The source Markdown files are currently assumed to be plain HTML with a Markdown header containing metadata. I'm going to need something to convert proper Markdown to HTML, so I'll probably add Pandoc as a dependency to squeeze.sh. I expect this will also replace Smartypants for doing smart punctuation. + ./unsqueeze.sh /home/user/website+ \ No newline at end of file diff --git a/squeeze.sh b/squeeze.sh @@ -16,9 +16,12 @@ find "$SITE_PATH"/"$SOURCE_DIR" -type f -name "*.md" -print0 | while IFS= read -r -d '' file; do echo $file NEW_PATH=`echo "$file" | sed "s|^$SITE_PATH/$SOURCE_DIR|$SITE_PATH/$OUTPUT_DIR|" | sed 's|.md$|.html|'` - cat "$file" | - swipl --traditional -q -l parse_entry.pl -g "consult('$SITE_PATH/site.pl'), generate_entry." | - smartypants \ + # Get everything after the metadata and feed it through Pandoc. + sed "1,/^$/d" "$file" | + pandoc --ascii --from markdown+smart --to html | + # Recombine with the metadata and hand it to Prolog. + (sed "/^$/q" "$file" && cat) | + swipl --traditional -q -l parse_entry.pl -g "consult('$SITE_PATH/site.pl'), generate_entry." \ > "$NEW_PATH" done