#!/bin/bash # Generate HTML from txt2tags (.t2t) and Markdown (.md) # Usage: # - update_html # Look for all .t2t and .md files in the current directory and below, # generating the output HTML when the source is newer than the HTML. # - update_html path/to/file.t2t path/to/another.md # Generate HTML for the specified file(s), ignoring modification time. # # Requires: # - txt2tags for .t2t files. Tested with 2.6. # - pandoc for both .t2t and .md files. Tested with 1.16.0.2 and 2.3.1. # - the template file `template.html` in the same directory as this script. # # Tested with Ubuntu 16.04 and macOS Mojave. # # See also clean_html for removing the files generated by this script. # Path to directory where this script is # https://stackoverflow.com/a/246128/98600 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" # HTML template template="$DIR/template.html" # Render txt2tags into html file # Arguments: # 1. txt2tags source file, e.g. download/index.t2t # 2. html target file, e.g. download/index.html function render_t2t_html { t2t="$1" html="$2" tmp="$2.tmp" relroot="$( dirname $t2t | sed -E 's/^.\///' | sed -E 's/[^/]+/../g' )" # First render with txt2tags to handle pre/post processing txt2tags \ --target=html \ --no-headers \ --quiet \ --outfile="$tmp" \ --infile="$t2t" # Replace with
so that Pandoc retains it # Do this for both cases since BSD sed doesn't support /i sed -i.bak "s/<\/a>/