fail() { printf '%s\n' "$@"; exit 1; }
awk() { /bin/awk "$@"; }
-md() { awk -f markdown.awk "$@"; }
+md_gawk() { gawk -f markdown.awk "$@"; }
+md_bawk() { busybox awk -f markdown.awk "$@"; }
+md_mawk() { mawk -f markdown.awk "$@"; }
acnt=1 # assertion count
assert() {
- local md="$(printf '%s' "$1" |md)" comp="$2" msg="$3"
+ local md comp="$2" msg="$3"
printf "%3i: %s ... " $acnt "$msg"
- if [ "$md" != "$comp" ]; then
- printf "Fail!\n:\n%s\n:\n%s\n" "$md" "$comp"
- exit 1
- fi
+
+ for proc in gawk bawk; do
+ printf '%s ' $proc
+ md="$(printf '%s' "$1" |md_"$proc")"
+ if [ "$md" != "$comp" ]; then
+ printf "Fail!\n:\n%s\n:\n%s\n" "$md" "$comp"
+ exit 1
+ fi
+ done
printf 'OK\n'
acnt=$((acnt + 1))
}
::::' \
'<div class="tag"><p>fenced <em>divs</em> are regular text</p>
-<div class=""><p>and can contain another div</p>
+<div><p>and can contain another div</p>
</div>
</div>' \
"pandoc fenced divs"
</dl>' \
'Definition List'
+assert ' * list
+* item
+ 1. sub list
+* three
+- new list' \
+'<ul>
+<li>list</li>
+<li><p>item</p>
+<ol>
+<li>sub list</li>
+</ol>
+</li>
+<li>three</li>
+</ul>
+<ul>
+<li>new list</li>
+</ul>' \
+'Lists'
+
+assert '::: outer div
+Nesting paragraph
+
+-------
+
+> ```
+> quoted code
+> ```
+>
+> > quoted quote
+:::
+' \
+'<div class="outer div"><p>Nesting paragraph</p>
+
+<hr>
+
+<blockquote><pre><code>quoted code</code></pre>
+<blockquote><p>quoted quote</p></blockquote>
+</blockquote>
+
+</div>' \
+"Nesting"
+
printf '\nAll test passed!\n'