From cf031847b06efb1b7492d49993ffc875205f2f03 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 17 Mar 2016 04:44:31 +0100 Subject: [PATCH] add pants and pandoc template --- .gitignore | 2 +- _templates/main.html | 125 +++++++++++++++++++++++++++++++++++++++++++ pants | 28 ++++++++++ 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 _templates/main.html create mode 100755 pants diff --git a/.gitignore b/.gitignore index 04bc145d..72e8ffc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -_* +* diff --git a/_templates/main.html b/_templates/main.html new file mode 100644 index 00000000..5225477a --- /dev/null +++ b/_templates/main.html @@ -0,0 +1,125 @@ + + + + + + +$for(author-meta)$ + +$endfor$ +$if(date-meta)$ + +$endif$ + $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ + + +$if(quotes)$ + +$endif$ +$if(highlighting-css)$ + +$endif$ + + + + + + + +$for(css)$ + +$endfor$ +$if(math)$ + $math$ +$endif$ +$for(header-includes)$ + $header-includes$ +$endfor$ + + +$for(include-before)$ +$include-before$ +$endfor$ + + + + + + + +$if(toc)$ + +$endif$ + +
+ +$if(title)$ +
+ +$if(subtitle)$ +

$subtitle$

+$endif$ +$for(author)$ +
$author$
+$endfor$ +$if(date)$ +

$date$

+$endif$ +
+$endif$ + +$body$ +
+ +
+

This project is maintained by @soimort.

+
+ +
+ + + +$for(include-after)$ +$include-after$ +$endfor$ + + diff --git a/pants b/pants new file mode 100755 index 00000000..80e6a990 --- /dev/null +++ b/pants @@ -0,0 +1,28 @@ +#!/bin/bash + +OUTDIR=. # where to put generated HTML files +SRCDIR=. # where your source files are +SRCEXT=md # extension of source files +PANDOC=pandoc +PANDOC_OPTIONS='--mathml --toc --toc-depth=2' +TEMPLATE=_templates/main.html + +all=() +while IFS= read -d $'\0' -r f ; do + all=("${all[@]}" "$f") +done < <(find $SRCDIR -path ./.git -prune -o -name '*.'$SRCEXT -print0) +echo Found source: ${all:?No source file found} + +for i in `ls -rv ${all[@]}`; do + if [ -f "$i" -a -n "${i%%*/_*}" ]; then # ignore underscored filenames + j="$OUTDIR/${i##$SRCDIR/}" + k="${j%.$SRCEXT}.html" + echo -e "$i\n\t->\t$k" + mkdir -p "${k%/*.html}" + $PANDOC $PANDOC_OPTIONS -s --template $TEMPLATE $i -o $k + fi +done + +if [ -n "$1" ]; then # run your server + ruby -run -e httpd $OUTDIR -p 4000 +fi