add in a handful of test to verify that empty pandoc headers are not auto-populated with %

This commit is contained in:
david parsons
2018-09-07 15:41:40 -07:00
parent 06ac2cc08f
commit c4c753da12
4 changed files with 69 additions and 17 deletions
+5 -2
View File
@@ -19,7 +19,7 @@ OBJS=mkdio.o markdown.o dumptree.o generate.o \
xml.o Csio.o xmlpage.o basename.o emmatch.o \
github_flavoured.o setup.o tags.o html5.o flags.o \
@AMALLOC@ @H1TITLE@
TESTFRAMEWORK=echo cols branch
TESTFRAMEWORK=echo cols branch pandoc_headers
# modules that markdown, makepage, mkd2html, &tc use
COMMON=pgm_options.o gethopt.o notspecial.o
@@ -118,10 +118,13 @@ verify: echo tools/checkbits.sh
@./echo -n "headers ... "; tools/checkbits.sh && echo "GOOD"
test: $(PGMS) $(TESTFRAMEWORK) verify
@for x in tests/*.t; do \
@for x in $${TESTS:-tests/*.t}; do \
@LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
done
pandoc_headers: tools/pandoc_headers.c config.h
$(CC) $(CFLAGS) $(LFLAGS) -o pandoc_headers \
tools/pandoc_headers.c $(COMMON) -lmarkdown
branch: tools/branch.c config.h
$(CC) -o branch tools/branch.c
cols: tools/cols.c config.h
+10 -5
View File
@@ -27,6 +27,15 @@ summary() {
}
try_header() {
testcase=`./echo -n " $1" '........................................................' | ./cols 50`
__tests=`expr $__tests + 1`
test "$VERBOSE" && ./echo -n "$testcase"
}
try() {
unset FLAGS
while [ "$1" ]; do
@@ -37,11 +46,7 @@ try() {
esac
done
testcase=`./echo -n " $1" '........................................................' | ./cols 50`
__tests=`expr $__tests + 1`
test "$VERBOSE" && ./echo -n "$testcase"
try_header $1
case "$2" in
-t*) Q=`./markdown $FLAGS "$2"` ;;
+47
View File
@@ -40,5 +40,52 @@ try 'indented header' \
% author(s)
% date</p>'
# verify that empty pandoc header elements are handled properly
check_null() {
try_header "$3"
res=`echo "$2" | ./pandoc_headers $1`
if [ "$res" ]; then
./echo
test $VERBOSE || ./echo "$3"
echo "$res"
else
test $VERBOSE && ./echo " ok"
fi
}
# pandoc headers left empty
EMPTY='%
%
%
stuff'
# pandoc headers with whitespace, but no content
EMPTY1='%
%
%
stuff'
AUTHOR='%
% bofh
%
stuff'
TITLE='%bofh
%
%
stuff'
DATE='%
%
%now
stuff'
check_null -atd "$EMPTY" "empty"
check_null -atd "$EMPTY1" "whitespace"
check_null -td "$AUTHOR" "author field"
check_null -ad "$TITLE" "title field"
check_null -at "$DATE" "date field"
summary $0
exit $rc
@@ -26,7 +26,7 @@
#include "amalloc.h"
#include "gethopt.h"
char *pgm = "check pandoc";
char *pgm = "pandoc headers";
void
fail(char *why, ...)
@@ -82,19 +82,16 @@ char **argv;
fail("could not compile input?");
if (show_author) {
res = mkd_doc_author(p);
printf("author:"); if ( res ) printf("%s", res);
putchar('\n');
if ( res = mkd_doc_author(p) )
printf("author: %s\n", res);
}
if (show_title) {
res = mkd_doc_title(p);
printf("title :"); if ( res ) printf("%s", res);
putchar('\n');
if ( res = mkd_doc_title(p) )
printf("title : %s\n", res);
}
if (show_date) {
res = mkd_doc_date(p);
printf("date :"); if ( res ) printf("%s", res);
putchar('\n');
if ( res = mkd_doc_date(p) )
printf("date : %s\n", res);
}
mkd_cleanup(p);
exit(0);