#!/bin/bash if [ "$1" != "--rst" -o $# -ne 2 ] && [ "$1" != "--md" -o $# -ne 3 ]; then echo "Usage: edithtml.sh --rst " echo " or: edithtml.sh --md " exit fi if [ "$1" == "--rst" ]; then sed -i.sedbak 's|</head>|<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="css/style.css"></head>|' $2 sed -i.sedbak 's|http://cdn.mathjax.org/mathjax/latest/MathJax.js|https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js|' $2 else cat - $2 >$2.prefix <<EOF <!DOCTYPE html> <html> <head> <title>$3 EOF cat $2.prefix - >$2 < EOF rm -f $2.prefix fi sed -i.sedbak 's|||g' $2 # Put
and ... on the same line. sed -i.sedbak -n '$!N;s|
\s*\n\s*\([^<]*\)|
\3 |' $2 rm -f *.sedbak