tryify compat.t, emphasis.t, and linkypix.t

This commit is contained in:
David Parsons
2009-06-17 17:26:37 -07:00
parent 5bd99c2fd0
commit d1a76a5cb4
3 changed files with 78 additions and 124 deletions
+29 -50
View File
@@ -3,66 +3,45 @@
rc=0
MARKDOWN_FLAGS=
try() {
unset FLAGS
case "$1" in
-*) FLAGS=$1
shift ;;
esac
./echo -n " $1" '..................................' | ./cols 36
Q=`./echo "$2" | ./markdown $FLAGS`
if [ "$3" = "$Q" ]; then
./echo " ok"
else
./echo " FAILED"
./echo "wanted: $3"
./echo "got : $Q"
rc=1
fi
}
LINKY='[this] is a test
[this]: /this'
./echo -n ' implicit reference links ......... '
RES=`./echo "$LINKY" | ./markdown`
count=`./echo "$RES" | grep -i '<a' | wc -l`
rest=`./echo "$RES" | grep ' is a test' | wc -l`
if [ \( "$count" -eq 1 \) -a \( "$rest" -eq 1 \) ]; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' implicit reference links (-f1.0) . '
RES=`./echo "$LINKY" | ./markdown -f1.0`
count=`./echo "$RES" | grep -i '<a' | wc -l`
if [ "$count" -eq 0 ]; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
try 'implicit reference links' "$LINKY" '<p><a href="/this">this</a> is a test</p>'
try -f1.0 'implicit reference links (-f1.0)' "$LINKY" '<p>[this] is a test</p>'
WSP=' '
WHITESPACE="
white space$WSP
and more"
./echo -n ' trailing whitespace .............. '
try 'trailing whitespace' "$WHITESPACE" '<pre><code>white space ''
and more
</code></pre>'
RES=`echo "$WHITESPACE" | ./markdown`
count=`echo "$RES" | grep -i ' $' | wc -l`
if [ $count -eq 1 ]; then
./echo "ok"
else
./echo "failed"
rc=1
fi
./echo -n ' trailing whitespace (-f1.0) ...... '
RES=`echo "$WHITESPACE" | ./markdown -f1.0`
count=`echo "$RES" | grep -i ' $' | wc -l`
if [ $count -eq 0 ]; then
./echo "ok"
else
./echo "failed ($count)"
rc=1
fi
try -f1.0 'trailing whitespace (-f1.0)' "$WHITESPACE" '<pre><code>white space''
and more
</code></pre>'
exit $rc
+26 -67
View File
@@ -2,80 +2,39 @@
rc=0
MARKDOWN_FLAGS=
MARKDOWN_VERSION=`./markdown -V`
./echo -n ' *hi* -> <em>hi</em> .............. '
try() {
unset FLAGS
case "$1" in
-*) FLAGS=$1
shift ;;
esac
./echo -n " $1" '..................................' | ./cols 36
if ./echo '*hi*' | ./markdown | grep -i '<em>hi</em>' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
Q=`./echo "$2" | ./markdown $FLAGS`
./echo -n ' * -> * ........................... '
if [ "$3" = "$Q" ]; then
./echo " ok"
else
./echo " FAILED"
./echo "wanted: $3"
./echo "got : $Q"
rc=1
fi
}
if ./echo 'A * A' | ./markdown | grep -i 'A \* A' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' ***A**B* ......................... '
if ./echo '***A**B*' | ./markdown -fnorelax | grep -i '<em><strong>A</strong>B</em>' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' ***A*B** ......................... '
if ./echo '***A*B**' | ./markdown -fnorelax | grep -i '<strong><em>A</em>B</strong>' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' **A*B*** ......................... '
if ./echo '**A*B***' | ./markdown -fnorelax | grep -i '<strong>A<em>B</em></strong>' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' *A**B*** ......................... '
if ./echo '*A**B***' | ./markdown -fnorelax | grep -i '<em>A<strong>B</strong></em>' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
try '*hi* -> <em>hi</em>' '*hi*' '<p><em>hi</em></p>'
try '* -> *' 'A * A' '<p>A * A</p>'
try -fstrict '***A**B*' '***A**B*' '<p><em><strong>A</strong>B</em></p>'
try -fstrict '***A*B**' '***A*B**' '<p><strong><em>A</em>B</strong></p>'
try -fstrict '**A*B***' '**A*B***' '<p><strong>A<em>B</em></strong></p>'
try -fstrict '*A**B***' '*A**B***' '<p><em>A<strong>B</strong></em></p>'
if ./markdown -V | grep RELAXED >/dev/null; then
./echo -n ' _A_B with -frelax ................ '
if ./echo '_A_B' | ./markdown -frelax | grep -i 'A_B' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' _A_B with -fstrict ............... '
if ./echo '_A_B' | ./markdown -fstrict | grep -i 'A</em>B' > /dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
try -frelax '_A_B with -frelax' '_A_B' '<p>_A_B</p>'
try -fstrict '_A_B with -fstrict' '_A_B' '<p><em>A</em>B</p>'
fi
exit $rc
+23 -7
View File
@@ -3,13 +3,29 @@
rc=0
MARKDOWN_FLAGS=
./echo -n ' image with size extension ........ '
try() {
unset FLAGS
case "$1" in
-*) FLAGS=$1
shift ;;
esac
./echo -n " $1" '..................................' | ./cols 36
if ./echo '![picture](pic =200x200)' | ./markdown | grep -i 'width=' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
Q=`./echo "$2" | ./markdown $FLAGS`
if [ "$3" = "$Q" ]; then
./echo " ok"
else
./echo " FAILED"
./echo "wanted: $3"
./echo "got : $Q"
rc=1
fi
}
try 'image with size extension' \
'![picture](pic =200x200)' \
'<p><img src="pic" height="200" width="200" alt="picture" /></p>'
exit $rc