#!/bin/sh
# Simple script to publish blogs
# Example usage: ./publish.sh "Header Title" inputFile.txt
# Created by John D. Duncan, III
FILENAME=$(cat counter.txt)'_'$(echo $1 | awk '{print tolower($1);}')'.html';
echo $FILENAME
INFILE=$(sed -re '
s/$/
/; # replace newline with
s/\t/\ \ \ /g;
s/&/\\&/g; # ampersand fixes
s/>>(.*)\.
/<\/p>
\1\. <\/blockquote>/g; # replace > .* \.
with blockquote s/\*\*([a-zA-Z0-9[:space:]_]+)\*\*/\1<\/b>/g; # replace ** with s/\_\_([a-zA-Z0-9[:space:]_]+)\_\_/\1<\/b>/g; # replace __ with s/\~\~([a-zA-Z0-9[:space:]_]+)\~\~/\1<\/s>/g; # replace ~~ withs/```([a-zA-Z0-9[:space:]_]+
)/\1/g; s/([a-zA-Z0-9[:space:]_]+)```
/\1<\/code>/g; s/`(.*)`/\1<\/code>/g; # replace ` with
s/---/<\/p>
/g; # replace --- with
s/\*\*\*/<\/p>/g; # replace *** with
s/\-\_([a-zA-Z0-9[:space:]_]+)\_\-/\1<\/small>/g; # replace -_ .* _- with s/\#\#([a-zA-Z0-9[:space:]_]+)\#\#/\1<\/u>/g; # replace ## with s/\%\%(.*)\%\%/\1<\/mark>/g; # replace %% with s/\_\{([a-zA-Z0-9[:space:]_,]+)\}/\1<\/sub>/g; # replace _{} with s/\^\{([a-zA-Z0-9[:space:]_,]+)\}/\1<\/sup>/g; # replace ^{} with s/\_([a-zA-Z0-9[:space:]_]+)\_/\1<\/i>/g; # replace _ with s/\*([a-zA-Z0-9[:space:]_]+)\*/\1<\/i>/g; # replace * with s/\!\[(.*)\]\((.*)\)//g; # markdown url (force unwrap image) s/\[(.*)\]\((.*)\)/\1<\/a>/g; # markdown url s/\[(.*)\]<([a-zA-Z0-9[:space:]_,]*)>/\1<\/abbr>/g; # replace []<> with s|[[:space:]](http[:]//[^ ]*[a-zA-Z])[[:space:]]| \1 |g; # replace urls with html urls s|https[:]\/\/www.youtube.com\/watch\?v=([a-zA-Z0-9_]*)|