awk() { /bin/awk "$@"; }
md() { awk -f markdown.awk "$@"; }
-tcount=1
+acnt=1 # assertion count
assert() {
local md="$(printf '%s' "$1" |md)" comp="$2" msg="$3"
- printf "%2i: %s ... " $tcount "$msg"
+ printf "%3i: %s ... " $acnt "$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))
+ acnt=$((acnt + 1))
}
# Inline checks
'paragraphs'
assert '%meta *data block*
- ignored `no` __formatting__' \
-'' \
+ ignored `no` __formatting__
+regular *data*' \
+'<p>regular <em>data</em></p>' \
"meta data block"
+assert '> text in a block
+> quote can be *emphasized*
+and quotes continued
+
+until they end' \
+'<blockquote><p>text in a block
+quote can be <em>emphasized</em>
+and quotes continued</p></blockquote>
+
+<p>until they end</p>' \
+'block quote'
+
+assert '| text in a line
+| block can be *emphasized*
+but not continued
+
+until they end' \
+'<div class="line-block">text in a line<br>
+block can be <em>emphasized</em></div>
+<p>but not continued</p>
+
+<p>until they end</p>' \
+'pandoc line block'
+
+assert ' indented code will
+ not be
+ *formatted*
+ but ­ <escaped>' \
+'<pre><code>indented code will
+not be
+*formatted*
+but &shy; <escaped></code></pre>' \
+"indented code block"
+
+assert ':::: tag
+fenced _divs_ are regular text
+
+:::
+and can contain another div
+:::
+::::' \
+'<div class="tag"><p>fenced <em>divs</em> are regular text</p>
+
+<div class=""><p>and can contain another div</p>
+</div>
+</div>' \
+"pandoc fenced divs"
+
+assert '``` tag,code
+fenced code will
+not be
+*formatted*
+but ­ <escaped>
+```' \
+'<pre><code class="tag code">fenced code will
+not be
+*formatted*
+but &shy; <escaped></code></pre>' \
+"fenced code block"
+
+# Block Images
+assert '![Testbild](Test Bild.jpg)' \
+'<figure data-src="Test Bild.jpg"><img src="Test Bild.jpg" alt="Testbild"></figure>' \
+"block image"
+
+assert '![Testbild](Test Bild.jpg "German Television *test* image ca. 1994")' \
+'<figure data-src="Test Bild.jpg"><img src="Test Bild.jpg" alt="Testbild"><figcaption>German Television <em>test</em> image ca. 1994</figcaption></figure>' \
+"inline image"
+
+assert '![Testbild *ARD*](Test Bild.jpg){tv ard function-check}' \
+'<figure data-src="Test Bild.jpg" class="tv ard function-check"><img src="Test Bild.jpg" alt="Testbild *ARD*" class="tv ard function-check"></figure>' \
+"block image tagged"
+
+# assert '![Testbild *ARD*](Test Bild.jpg){#tv .ard .function-check}' \
+# '<figure data-src="Test Bild.jpg" class="tv ard function-check"><img src="Test Bild.jpg" alt="Testbild *ARD*" class="tv ard function-check"></figure>' \
+# "block image tagged"
+
printf '\nAll test passed!\n'