--- /dev/null
+#!/bin/sh
+
+BR='
+'
+CR="$(printf \r)"
+fail() { printf '%s\n' "$@"; exit 1; }
+
+awk() { /bin/awk "$@"; }
+md() { awk -f markdown.awk "$@"; }
+
+tcount=1
+assert() {
+ local md="$(printf '%s' "$1" |md)" comp="$2" msg="$3"
+ printf "%2i: %s ... " $tcount "$msg"
+ if [ "$md" != "$comp" ]; then
+ printf "Fail!\n:\n%s\n:\n%s\n" "$md" "$comp"
+ exit 1
+ fi
+ printf 'OK\n'
+ tcount=$((tcount + 1))
+}
+
+# Inline checks
+printf '## Testing Inline markup ##\n'
+
+# strong / em / ...
+assert '~~strikeout~~' '<p><del>strikeout</del></p>' "strikeout"
+assert '~~~strikeout~~' '<p><del>~strikeout</del></p>' "strikeout"
+assert '^super^' '<p><sup>super</sup></p>' "superscript"
+assert '~sub~' '<p><sub>sub</sub></p>' "subscript"
+
+assert "foo ${BR}bar" "<p>foo<br>${BR}bar</p>" 'double space line break'
+assert '```©```' "<p><code>&copy;</code></p>" "code span escape"
+
+assert '_emphasized text_' '<p><em>emphasized text</em></p>' "em"
+assert '_emphasized_text_' '<p><em>emphasized_text</em></p>' "em"
+assert 'empha*sized* text_' '<p>empha<em>sized</em> text_</p>' "em"
+assert '__empha*sized* text__' '<p><strong>empha<em>sized</em> text</strong></p>' "strong em"
+assert '***strem***' '<p><strong><em>strem</em></strong></p>' "strong em"
+assert '***str**em*' '<p><em><strong>str</strong>em</em></p>' "em strong"
+assert '_**strem**_' '<p><em><strong>strem</strong></em></p>' "em strong"
+
+# Escaping
+assert "©" "<p>©</p>" "escape"
+assert "\©" "<p>&copy;</p>" "escape"
+assert "AT&T" "<p>AT&T</p>" "escape"
+assert '`©`' "<p><code>&copy;</code></p>" "code span escape"
+
+# Automatic Links
+assert '<https://de.wikipedia.org>' "<p><a href=\"https://de.wikipedia.org\">https://de.wikipedia.org</a></p>" "automatic link"
+assert '<http://de.wikipedia.org>' "<p><a href=\"http://de.wikipedia.org\">http://de.wikipedia.org</a></p>" "automatic link"
+# assert '<//de.wikipedia.org>' "<p><a href=\"//de.wikipedia.org\">http://de.wikipedia.org</a></p>" "automatic link"
+
+# Inline Links
+assert '[Wikipedia](http://de.wikipedia.org)' "<p><a href=\"http://de.wikipedia.org\">Wikipedia</a></p>" "inline link"
+assert '[Wikipedia](http://de.wikipedia.org "Online Encyclopedia")' "<p><a href=\"http://de.wikipedia.org\" title=\"Online Encyclopedia\">Wikipedia</a></p>" "inline link"
+assert '[Wikipedia](<http://de.wikipedia.org> "Online Encyclopedia")' "<p><a href=\"http://de.wikipedia.org\" title=\"Online Encyclopedia\">Wikipedia</a></p>" "inline link"
+
+# Inline Images (note leading white space)
+assert ' ' '<p> <img src="Test Bild.jpg" alt="Testbild"></p>' "inline image"
+assert ' ' '<p> <img src="Test Bild.jpg" alt="Testbild" title="German Television *test* image ca. 1994"></p>' "inline image"
+assert ' {tv ard function-check}' '<p> <img src="Test Bild.jpg" alt="Testbild *ARD*" class="tv ard function-check"></p>' "inline image"
+# assert ' {#tv .ard .function-check}' '<p> <img src="Test Bild.jpg" alt="Testbild *ARD*" class="tv ard check"></p>' "inline image id/classes"
+
+assert '[](<http://de.wikipedia.org>)'\
+ '<p><a href="http://de.wikipedia.org"><img src="wikilogo.png" alt="Wikipedia"></a></p>'\
+ "Image Link"
+
+# Block checks
+printf '\n## Testing Block markup ##\n'
+
+assert \
+'foo
+
+bar' \
+'<p>foo</p>
+
+<p>bar</p>' \
+'paragraphs'
+
+assert '%meta *data block*
+ ignored `no` __formatting__' \
+'' \
+"meta data block"
+
+printf '\nAll test passed!\n'