| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
16f3fba530 | discount-1.5.5 | 16 years ago |
| @ -1,90 +0,0 @@ | |||
| CC=@CC@ -I. -L. | |||
| AR=@AR@ | |||
| RANLIB=@RANLIB@ | |||
| BINDIR=@exedir@ | |||
| MANDIR=@mandir@ | |||
| LIBDIR=@libdir@ | |||
| INCDIR=@prefix@/include | |||
| PGMS=markdown | |||
| SAMPLE_PGMS=mkd2html makepage | |||
| @THEME@SAMPLE_PGMS+= theme | |||
| MKDLIB=libmarkdown.a | |||
| OBJS=mkdio.o markdown.o dumptree.o generate.o \ | |||
| resource.o docheader.o version.o toc.o Csio.o xmlpage.o @AMALLOC@ | |||
| all: $(PGMS) $(SAMPLE_PGMS) | |||
| install: $(PGMS) | |||
| @INSTALL_PROGRAM@ $(PGMS) $(BINDIR) | |||
| @INSTALL_DATA@ $(MKDLIB) $(LIBDIR) | |||
| @INSTALL_DATA@ mkdio.h $(INCDIR) | |||
| install.everything: install install.samples install.man | |||
| install.samples: $(SAMPLE_PGMS) install | |||
| @INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(BINDIR) | |||
| @INSTALL_DIR@ $(MANDIR)/man1 | |||
| @INSTALL_DATA@ theme.1 $(MANDIR)/man1 | |||
| install.man: | |||
| @INSTALL_DIR@ $(MANDIR)/man3 | |||
| @INSTALL_DATA@ mkd-functions.3 markdown.3 $(MANDIR)/man3 | |||
| for x in mkd_text mkd_in mkd_string; do \ | |||
| ( echo '.\"' ; echo ".so man3/markdown.3" ) > $(MANDIR)/man3/$$x.3;\ | |||
| done | |||
| for x in mkd_compile mkd_style mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \ | |||
| ( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(MANDIR)/man3/$$x.3; \ | |||
| done | |||
| @INSTALL_DIR@ $(MANDIR)/man7 | |||
| @INSTALL_DATA@ markdown.7 mkd-extensions.7 $(MANDIR)/man7 | |||
| @INSTALL_DIR@ $(MANDIR)/man1 | |||
| @INSTALL_DATA@ markdown.1 $(MANDIR)/man1 | |||
| install.everything: install install.man | |||
| version.o: version.c VERSION | |||
| $(CC) -DVERSION=\"`cat VERSION`\" -c version.c | |||
| markdown: main.o $(MKDLIB) | |||
| $(CC) -o markdown main.o -lmarkdown @LIBS@ | |||
| # example programs | |||
| @THEME@theme: theme.o $(MKDLIB) | |||
| @THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@ | |||
| mkd2html: mkd2html.o $(MKDLIB) | |||
| $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@ | |||
| makepage: makepage.c $(MKDLIB) | |||
| $(CC) -o makepage makepage.c -lmarkdown @LIBS@ | |||
| main.o: main.c mkdio.h config.h | |||
| $(CC) -I. -c main.c | |||
| $(MKDLIB): $(OBJS) | |||
| $(AR) crv $(MKDLIB) $(OBJS) | |||
| $(RANLIB) $(MKDLIB) | |||
| test: $(PGMS) echo | |||
| @for x in tests/*.t; do \ | |||
| sh $$x || exit 1; \ | |||
| done | |||
| echo: echo.c | |||
| $(CC) -o echo echo.c | |||
| clean: | |||
| rm -f $(PGMS) $(SAMPLE_PGMS) *.o $(MKDLIB) | |||
| distclean spotless: clean | |||
| rm -f @GENERATED_FILES@ @CONFIGURE_FILES@ | |||
| markdown.o: markdown.c config.h cstring.h markdown.h | |||
| generate.o: generate.c config.h cstring.h markdown.h | |||
| dumptree.o: dumptree.c cstring.h markdown.h | |||
| mkdio.o: mkdio.c mkdio.h cstring.h config.h | |||
| xmlpage.o: xmlpage.c mkdio.h cstring.h config.h | |||
| toc.o: toc.c mkdio.h cstring.h config.h | |||
| @ -1 +0,0 @@ | |||
| 1.3.4 | |||
| @ -1,49 +0,0 @@ | |||
| ./echo "code blocks" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' format for code block html ....... ' | |||
| SEP=' | |||
| this is | |||
| code | |||
| ' | |||
| count=`echo "$SEP" | ./markdown | wc -l` | |||
| if [ $count -eq 3 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' unclosed single backtick ......... ' | |||
| if ./echo '`hi there' | ./markdown | grep '`' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' unclosed double backtick ......... ' | |||
| if ./echo '``hi there' | ./markdown | grep '``' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' remove space around code ......... ' | |||
| if ./echo '`` hi there ``' | ./markdown | grep '<code>hi there<\/code>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,67 +0,0 @@ | |||
| ./echo "markdown 1.0 compatability" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| LINKY='[this] is a test | |||
| [this]: /this' | |||
| ./echo -n ' implicit reference links ......... ' | |||
| RES=`./echo "$LINKY" | ./markdown` | |||
| count=`./echo "$RES" | grep -i '<a' | wc -l` | |||
| if [ "$count" -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 | |||
| WSP=' ' | |||
| WHITESPACE=" | |||
| white space$WSP | |||
| and more" | |||
| ./echo -n ' trailing whitespace .............. ' | |||
| 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 | |||
| exit $rc | |||
| @ -1,82 +0,0 @@ | |||
| ./echo "definition lists" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| SEP=' | |||
| =this= | |||
| is an ugly | |||
| =test= | |||
| eh? | |||
| ' | |||
| RES=`./echo "$SEP" | ./markdown` | |||
| if ./markdown -V | grep DL_TAG >/dev/null; then | |||
| ./echo -n ' =tag= generates definition lists . ' | |||
| count=`./echo "$RES" | grep -i '<dl>' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' two item list has two labels ..... ' | |||
| count=`./echo "$RES" | grep -i '<dt>' | wc -l` | |||
| if [ $count -eq 2 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' two item list has two entries..... ' | |||
| count=`./echo "$RES" | grep -i '<dd>' | wc -l` | |||
| if [ $count -eq 2 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' one item with two =tags= ......... ' | |||
| SRC=" | |||
| =this= | |||
| =is= | |||
| A test, eh?" | |||
| RES=`./echo "$SRC" | ./markdown` | |||
| count1=`./echo "$RES" | grep -i '<dt>' | wc -l` | |||
| count2=`./echo "$RES" | grep -i '<dd>' | wc -l` | |||
| if [ \( "${count1:-0}" -eq 2 \) -a \( "${count2:-0}" -eq 1 \) ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| else | |||
| ./echo -n ' =tag= does nothing ............... ' | |||
| count=`./echo "$RES" | grep -i '<dl>' | wc -l` | |||
| if [ $count -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| fi | |||
| exit $rc | |||
| @ -1,81 +0,0 @@ | |||
| ./echo "emphasis" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| MARKDOWN_VERSION=`./markdown -V` | |||
| ./echo -n ' *hi* -> <em>hi</em> .............. ' | |||
| if ./echo '*hi*' | ./markdown | grep -i '<em>hi</em>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' * -> * ........................... ' | |||
| 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 | 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 | 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 | 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 | grep -i '<em>A<strong>B</strong></em>' > /dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| 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 | |||
| fi | |||
| exit $rc | |||
| @ -1,43 +0,0 @@ | |||
| ./echo "paragraph flow" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' header followed by paragraph ..... ' | |||
| SEP='###Hello, sailor### | |||
| And how are you today?' | |||
| RES=`./echo "$SEP" | ./markdown` | |||
| hcount=`./echo "$RES" | grep -i '<h3>' | wc -l` | |||
| pcount=`./echo "$RES" | grep -i '<p>' | wc -l` | |||
| if [ "$hcount" -eq 1 -a "$pcount" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' two lists punctuated with a HR ... ' | |||
| SEP='* A | |||
| * * * | |||
| * B | |||
| * C' | |||
| RES=`./echo "$SEP" | ./markdown` | |||
| hrcount=`./echo "$RES" | grep -i '<hr' | wc -l` | |||
| ulcount=`./echo "$RES" | grep -i '<ul>' | wc -l` | |||
| if [ "$hrcount" -eq 1 -a "$ulcount" -eq 2 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,33 +0,0 @@ | |||
| ./echo "footnotes" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' a line with multiple []s ......... ' | |||
| SZ=`./echo '[a][] [b][]:' | ./markdown | wc -l` | |||
| if [ "$SZ" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' a valid footnote ................. ' | |||
| FMT=' | |||
| [alink][] | |||
| [alink]: link me' | |||
| SZ=`./echo "$FMT" | ./markdown | grep '<a href' | wc -l` | |||
| if [ "$SZ" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,118 +0,0 @@ | |||
| ./echo "html blocks" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' self-closing block tags (hr) ..... ' | |||
| SEP=' | |||
| <hr> | |||
| text | |||
| ' | |||
| count=`./echo "$SEP" | ./markdown | grep '<p>' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' self-closing block tags (hr/) .... ' | |||
| SEP=' | |||
| <hr/> | |||
| text | |||
| ' | |||
| count=`./echo "$SEP" | ./markdown | grep '<p>' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' self-closing block tags (br) ..... ' | |||
| SEP=' | |||
| <br> | |||
| text | |||
| ' | |||
| count=`./echo "$SEP" | ./markdown | grep '<p>' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' html comments .................... ' | |||
| SEP=' | |||
| <!-- | |||
| **hi** | |||
| --> | |||
| ' | |||
| count=`./echo "$SEP" | ./markdown | grep 'strong' | wc -l` | |||
| if [ $count -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' no smartypants inside tags (#1) .. ' | |||
| count=`./echo '<img src="linky">' | ./markdown | tr -dc '"' | wc -c` | |||
| if [ $count -eq 2 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' no smartypants inside tags (#2) .. ' | |||
| count=`./echo '<img src="linky" alt=":)" />' | ./markdown | tr -dc '"' | wc -c` | |||
| if [ $count -eq 4 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' block html with -fnohtml ......... ' | |||
| RSLT=`./echo "<b>hi!</b>" | ./markdown -fnohtml` | |||
| if ./echo "$RSLT" | grep '<b>' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' allow html with -fhtml ........... ' | |||
| RSLT=`./echo "<b>hi!</b>" | ./markdown -fhtml` | |||
| if ./echo "$RSLT" | grep '<b>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,149 +0,0 @@ | |||
| ./echo "embedded links" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' url contains & ................... ' | |||
| if ./echo '[hehehe](u&rl)' | ./markdown | grep -i '&' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' quote link title with () ......... ' | |||
| if ./echo '[hehehe](url (link title))' | ./markdown | grep -i 'title="link title"' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' url contains + ................... ' | |||
| if ./echo '[hehehe](u+rl)' | ./markdown | grep -i '+' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' url contains " ................... ' | |||
| if ./echo '[hehehe](u"rl)' | ./markdown | grep -i '%22' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' url contains < ................... ' | |||
| if ./echo '[hehehe](u<rl)' | ./markdown | grep -i '<' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' label contains < ................. ' | |||
| if ./echo '' | ./markdown | grep -i '<' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' label contains < ................. ' | |||
| if ./echo '' | ./markdown | grep -i '<' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' sloppy context link .............. ' | |||
| if ./echo '[heh]( url "how about it?" )' | ./markdown | grep -i '</a>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' footnote urls formed properly .... ' | |||
| TEST='[hehehe]: hohoho "ha ha" | |||
| [hehehe][] | |||
| ' | |||
| if ./echo "$TEST" | ./markdown | grep -i '�' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' linky-like []s work .............. ' | |||
| if ./echo '[foo]' | ./markdown | fgrep '[foo]' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' pseudo-protocol "id:" ............ ' | |||
| if ./echo '[foo](id:bar)' | ./markdown | fgrep 'a id' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' pseudo-protocol "class:" ......... ' | |||
| if ./echo '[foo](class:bar)' | ./markdown | fgrep 'span class' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' nested [][]s ..................... ' | |||
| count=`./echo '[[z](y)](x)' | ./markdown | tr '>' '\n' | grep -i '<a href' | wc -l` | |||
| if [ "$count" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' empty [][] tags .................. ' | |||
| V=" | |||
| [![][1]][2] | |||
| [1]: image1 | |||
| [2]: image2" | |||
| count=`echo "$V" | ./markdown | fgrep '[]' | wc -l` | |||
| if [ "$count" -lt 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,15 +0,0 @@ | |||
| ./echo "embedded images" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' image with size extension ........ ' | |||
| if ./echo '' | ./markdown | grep -i 'width=' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,147 +0,0 @@ | |||
| ./echo "lists" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' two separated items (1) .......... ' | |||
| SEP=' * A | |||
| * B' | |||
| RES=`./echo "$SEP" | ./markdown` | |||
| count=`./echo "$RES" | grep -i '<ul>' | wc -l` | |||
| if [ "$count" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' two separated items (2) .......... ' | |||
| count=`./echo "$RES" | grep -i '<p>' | wc -l` | |||
| case `expr $count` in | |||
| 2) ./echo "ok" ;; | |||
| 1) ./echo "FAILED (known bug)" ;; | |||
| *) ./echo "FAILED ($count)" | |||
| rc=1 ;; | |||
| esac | |||
| ./echo -n ' two adjacent items ............... ' | |||
| SEP=' * A | |||
| * B' | |||
| count=`./echo "$SEP" | ./markdown | grep -i '<p>' | wc -l` | |||
| if [ "$count" -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' two adjacent items, then space ... ' | |||
| SEP=' * A | |||
| * B | |||
| space, the final frontier' | |||
| count=`./echo "$SEP" | ./markdown | grep -i '<p>' | wc -l` | |||
| if [ "$count" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' nested lists (1) ................. ' | |||
| SUB=' | |||
| 1. Sub (list) | |||
| 2. Two (items) | |||
| 3. Here' | |||
| SEP=' | |||
| * 1. Sub (list) | |||
| 2. Two (items) | |||
| 3. Here' | |||
| count1=`./echo "$SUB" | ./markdown | grep -i '<p>' | wc -l` | |||
| count=`./echo "$SEP" | ./markdown | grep -i '<p>' | wc -l` | |||
| if [ "$count" -eq "$count1" ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' nested lists (2) ................. ' | |||
| SUB=' | |||
| >A (list) | |||
| > | |||
| >1. Sub (list) | |||
| >2. Two (items) | |||
| >3. Here' | |||
| SEP=' | |||
| * A (list) | |||
| 1. Sub (list) | |||
| 2. Two (items) | |||
| 3. Here | |||
| Here | |||
| * B (list)' | |||
| count1=`./echo "$SUB" | ./markdown | grep -i '<p>' | wc -l` | |||
| count=`./echo "$SEP" | ./markdown | grep -i '<p>' | wc -l` | |||
| if [ "$count" -gt $count1 ] ; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' blockquote inside list ........... ' | |||
| SEP=' | |||
| * A (list) | |||
| > quote | |||
| > me | |||
| dont quote me' | |||
| if ./echo "$SEP" | ./markdown | grep 'blockquote' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' empty list ....................... ' | |||
| SEP=' | |||
| - | |||
| - | |||
| ' | |||
| if ./echo "$SEP" | ./markdown | grep '<li>' > /dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,25 +0,0 @@ | |||
| ./echo "deeply nested lists" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' thrice-nested lists .............. ' | |||
| LIST=' | |||
| * top-level list ( list 1) | |||
| + second-level list (list 2) | |||
| * first item third-level list (list 3) | |||
| + * second item, third-level list, first item. (list 4) | |||
| * second item, third-level list, second item. | |||
| * top-level list again.' | |||
| count=`./echo "$LIST" | ./markdown | grep -i '<ul>' | wc -l` | |||
| if [ "$count" -eq 4 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,46 +0,0 @@ | |||
| ./echo "misc" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' single paragraph ................. ' | |||
| RES=`./echo AAA | ./markdown` | |||
| count=`./echo "$RES" | grep -i '<p>' | wc -l` | |||
| if [ "$count" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' < -> < ........................ ' | |||
| if ./echo '<' | ./markdown | grep -i '<' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' `>` -> <code>></code> ......... ' | |||
| if ./echo '`>`' | ./markdown | grep -i '<code>></code>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' `` ` `` -> <code>`</code> ........ ' | |||
| if ./echo '`` ` ``' | ./markdown | grep '<code>`</code>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,96 +0,0 @@ | |||
| ./echo "pandoc headers" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| if ./markdown -V | grep HEADER > /dev/null; then | |||
| ./echo -n ' valid header ..................... ' | |||
| TEXT='% title | |||
| % author(s) | |||
| % date | |||
| ' | |||
| count=`./echo "$TEXT" | ./markdown | grep title | wc -l` | |||
| if [ "$count" -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' valid header with -F0x0100........ ' | |||
| TEXT='% title | |||
| % author(s) | |||
| % date | |||
| ' | |||
| count=`./echo "$TEXT" | ./markdown -F0x0100 | grep title | wc -l` | |||
| if [ "$count" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' invalid header ................... ' | |||
| TEXT='% title | |||
| % author(s) | |||
| a pony!' | |||
| count=`./echo "$TEXT" | ./markdown | grep title | wc -l` | |||
| if [ "$count" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' offset header .................... ' | |||
| TEXT=' | |||
| % title | |||
| % author(s) | |||
| % date | |||
| content' | |||
| count=`./echo "$TEXT" | ./markdown | grep title | wc -l` | |||
| if [ "$count" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' indented header .................. ' | |||
| TEXT=' % title | |||
| % author(s) | |||
| % date | |||
| content' | |||
| count=`./echo "$TEXT" | ./markdown | grep title | wc -l` | |||
| if [ "$count" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| else | |||
| ./echo -n ' ignore headers ................... ' | |||
| TEXT='% title | |||
| % author(s) | |||
| % date | |||
| ' | |||
| count=`./echo "$TEXT" | ./markdown | grep title | wc -l` | |||
| if [ "$count" -gt 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| fi | |||
| exit $rc | |||
| @ -1,32 +0,0 @@ | |||
| ./echo "paragraph blocking" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' paragraph followed by code ....... ' | |||
| SEP="a | |||
| b" | |||
| RES=`./echo "$SEP" | ./markdown` | |||
| pcount=`./echo "$RES" | grep -i '<p>' | wc -l` | |||
| ccount=`./echo "$RES" | grep -i '<code>' | wc -l` | |||
| if [ "$ccount" -eq 1 -a "$pcount" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' single-line paragraph ............ ' | |||
| if ./echo "a" | ./markdown | grep '<p>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,85 +0,0 @@ | |||
| ./echo "markup peculiarities" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' list followed by header .......... ' | |||
| SRC=" | |||
| - AAA | |||
| - BBB | |||
| -" | |||
| count=`./echo "$SRC" | ./markdown | sed -e '1,/<\/ul>/d' | wc -l` | |||
| if [ "$count" -gt 1 ]; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' ul with mixed item prefixes ...... ' | |||
| SRC=" | |||
| - A | |||
| 1. B | |||
| " | |||
| RES=`echo "$SRC" | ./markdown` | |||
| ulc=`./echo "$RES" | grep '<ul>' | wc -l` | |||
| olc=`./echo "$RES" | grep '<ol>' | wc -l` | |||
| if [ $ulc -eq 1 -a $olc -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' ol with mixed item prefixes ...... ' | |||
| SRC=" | |||
| 1. A | |||
| - B | |||
| " | |||
| RES=`echo "$SRC" | ./markdown` | |||
| ulc=`./echo "$RES" | grep '<ul>' | wc -l` | |||
| olc=`./echo "$RES" | grep '<ol>' | wc -l` | |||
| if [ $olc -eq 1 -a $ulc -eq 0 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' forcing a <br/> .................. ' | |||
| SRC="this " | |||
| count=`echo "$SRC" | ./markdown | grep '<br/>' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' trimming single spaces ........... ' | |||
| SRC="this " | |||
| count=`echo "$SRC" | ./markdown | grep 'this ' | wc -l` | |||
| if [ $count -eq 1 ]; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| exit $rc | |||
| @ -1,76 +0,0 @@ | |||
| ./echo "pseudo-protocols" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' [](id:) links .................... ' | |||
| ASK=`./echo '[foo](id:bar)' | ./markdown` | |||
| if ./echo "$ASK" | grep '<a id="bar">foo</a>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' [](id:) links with MKD_NO_EXT .... ' | |||
| ASK=`./echo '[foo](id:bar)' | MARKDOWN_FLAGS=0x0040 ./markdown` | |||
| if ./echo "$ASK" | grep '<a id="bar">foo</a>' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' [](class:) links ................. ' | |||
| ASK=`./echo '[foo](class:bar)' | ./markdown` | |||
| if ./echo "$ASK" | grep '<span class="bar">foo</span>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' [](class:) links with MKD_NO_EXT . ' | |||
| ASK=`./echo '[foo](class:bar)' | MARKDOWN_FLAGS=0x0040 ./markdown` | |||
| if ./echo "$ASK" | grep '<span class="bar">foo</span>' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' [](raw:) links ................... ' | |||
| ASK=`./echo '[foo](raw:bar)' | ./markdown` | |||
| count1=`./echo "$ASK" | grep foo | wc -l` | |||
| count2=`./echo "$ASK" | grep bar | wc -l` | |||
| if [ "$count1" -eq 0 -a "$count2" -eq 1 ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' [](raw:) links with MKD_NO_EXT ... ' | |||
| ASK=`./echo '[foo](raw:bar)' | MARKDOWN_FLAGS=0x0040 ./markdown` | |||
| count1=`./echo "$ASK" | grep 'raw:bar' | wc -l` | |||
| count2=`./echo "$ASK" | grep 'a href' | wc -l` | |||
| if [ \( "$count1" -gt 0 \) -a \( "$count2" -gt 0 \) ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,18 +0,0 @@ | |||
| ./echo "footnotes inside reparse sections" | |||
| rc=0 | |||
| RES="[![foo][]](bar) | |||
| [foo]: bar2" | |||
| ./echo -n ' footnote inside [] section ....... ' | |||
| if ./echo "$RES" | ./markdown | fgrep bar2 >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| exit $rc | |||
| @ -1,140 +0,0 @@ | |||
| ./echo "smarty pants" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| MARKDOWN_FLAGS=0x0; export MARKDOWN_FLAGS | |||
| ./echo -n ' (c) -> © .................... ' | |||
| if ./echo '(c)' | ./markdown | grep '©' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' (r) -> ® ..................... ' | |||
| if ./echo '(r)' | ./markdown | grep '®' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' (tm) -> ™ .................. ' | |||
| if ./echo '(tm)' | ./markdown | grep '™' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' ... -> … .................. ' | |||
| if ./echo '...' | ./markdown | grep '…' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' -- -> — .................... ' | |||
| if ./echo '--' | ./markdown | grep '—' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' - -> – ..................... ' | |||
| if ./echo 'regular - ' | ./markdown | grep '–' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' A-B -> A-B ....................... ' | |||
| if ./echo 'A-B' | ./markdown | grep '–' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' "fancy" -> “fancy” ... ' | |||
| if ./echo '"fancy"' | ./markdown | grep '“fancy”' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' '"'fancy'"' -> ‘fancy’ ... ' | |||
| if ./echo "'fancy'" | ./markdown | grep '‘fancy’' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n " don<b>'t -> don<b>’t ....... " | |||
| if ./echo "don<b>'t" | ./markdown | grep 'don<b>’t' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n " don't -> don’t ............. " | |||
| if ./echo "don't" | ./markdown | grep 'don’t' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n " it's -> it’s ............... " | |||
| if ./echo "it's" | ./markdown | grep 'it’s' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| if ./markdown -V | grep SUPERSCRIPT >/dev/null; then | |||
| ./echo -n " A^B -> A<sup>B</sup> (-frelax) ... " | |||
| if ./echo "A^B" | ./markdown -frelax | grep '<sup>B</sup>' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n " A^B != A<sup>B</sup> (-fstrict) .. " | |||
| if ./echo "A^B" | ./markdown -fstrict | grep '<sup>B</sup>' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n " A^B in link title ................ " | |||
| if ./echo "[link](here 'A^B')" | ./markdown -frelax | grep '<sup>B</sup>' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| fi | |||
| exit $rc | |||
| @ -1,29 +0,0 @@ | |||
| rc=0 | |||
| unset MARKDOWN_FLAGS | |||
| unset MKD_TABSTOP | |||
| eval `./markdown -V | tr ' ' '\n' | grep TAB` | |||
| if [ "${TAB:-4}" -eq 8 ]; then | |||
| ./echo "dealing with tabstop derangement" | |||
| LIST=' | |||
| * A | |||
| * B | |||
| * C' | |||
| count1=`./echo "$LIST" | ./markdown | grep -i '<ul>' | wc -l` | |||
| count2=`./echo "$LIST" | MARKDOWN_FLAGS=0x0200 ./markdown | grep -i '<ul>' | wc -l` | |||
| ./echo -n ' MARKDOWN_FLAGS breaks tabstops ... ' | |||
| if [ "$count1" -ne "$count2" ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| fi | |||
| exit $rc | |||
| @ -1,44 +0,0 @@ | |||
| ./echo "xml output with MKD_CDATA" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| ./echo -n ' xml output from markdown() ....... ' | |||
| if ./echo '"hello,sailor"' | ./markdown -fcdata | grep '&' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' html output from markdown() ...... ' | |||
| if ./echo '"hello,sailor"' | ./markdown -fnocdata | grep '&' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| ./echo -n ' xml output from mkd_text() ....... ' | |||
| if ./markdown -fcdata -t'"hello,sailor"' | grep '&' >/dev/null; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| fi | |||
| ./echo -n ' html output from mkd_text() ...... ' | |||
| if ./markdown -fnocdata -t'"hello,sailor"' | grep '&' >/dev/null; then | |||
| ./echo "FAILED" | |||
| rc=1 | |||
| else | |||
| ./echo "ok" | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,33 @@ | |||
| Discount is primarily my work, but it has only reached the point | |||
| where it is via contributions, critiques, and bug reports from a | |||
| host of other people, some of which are listed before. If your | |||
| name isn't on this list, please remind me | |||
| -david parsons (orc@pell.chi.il.us) | |||
| Josh Wood -- Plan9 support. | |||
| Mike Schiraldi -- Reddit style automatic links, MANY MANY MANY | |||
| bug reports about boundary conditions and | |||
| places where I didn't get it right. | |||
| Jjgod Jiang -- Table of contents support. | |||
| Petite Abeille -- Many bug reports about places where I didn't | |||
| get it right. | |||
| Tim Channon -- inspiration for the `mkd_xhtmlpage()` function | |||
| Christian Herenz-- Many bug reports regarding my implementation of | |||
| `[]()` and `![]()` | |||
| A.S.Bradbury -- Portability bug reports for 64 bit systems. | |||
| Joyent -- Loan of a solaris box so I could get discount | |||
| working under solaris. | |||
| Ryan Tomayko -- Portability requests (and the rdiscount ruby | |||
| binding.) | |||
| yidabu -- feedback on the documentation, bug reports | |||
| against utf-8 support. | |||
| Pierre Joye -- bug reports, php discount binding. | |||
| Masayoshi Sekimura- perl discount binding. | |||
| Jeremy Hinegardner- bug reports about list handling. | |||
| Andrew White -- bug reports about the format of generated urls. | |||
| Steve Huff -- bug reports about Makefile portability (for Fink) | |||
| Ignacio Burgue?o-- bug reports about `>%class%` | |||
| Henrik Nyh -- bug reports about embedded html handling. | |||
| @ -0,0 +1,96 @@ | |||
| CC=@CC@ -I. -L. | |||
| AR=@AR@ | |||
| RANLIB=@RANLIB@ | |||
| BINDIR=@exedir@ | |||
| MANDIR=@mandir@ | |||
| LIBDIR=@libdir@ | |||
| INCDIR=@prefix@/include | |||
| PGMS=markdown | |||
| SAMPLE_PGMS=mkd2html makepage | |||
| @THEME@SAMPLE_PGMS+= theme | |||
| MKDLIB=libmarkdown.a | |||
| OBJS=mkdio.o markdown.o dumptree.o generate.o \ | |||
| resource.o docheader.o version.o toc.o css.o \ | |||
| xml.o Csio.o xmlpage.o @AMALLOC@ | |||
| all: $(PGMS) $(SAMPLE_PGMS) | |||
| install: $(PGMS) | |||
| @INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)/$(BINDIR) | |||
| @INSTALL_DATA@ $(MKDLIB) $(DESTDIR)/$(LIBDIR) | |||
| @INSTALL_DATA@ mkdio.h $(DESTDIR)/$(INCDIR) | |||
| install.everything: install install.samples install.man | |||
| install.samples: $(SAMPLE_PGMS) install | |||
| @INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(DESTDIR)/$(BINDIR) | |||
| @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1 | |||
| @INSTALL_DATA@ theme.1 $(DESTDIR)/$(MANDIR)/man1 | |||
| install.man: | |||
| @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man3 | |||
| @INSTALL_DATA@ mkd-functions.3 markdown.3 mkd-line.3 $(DESTDIR)/$(MANDIR)/man3 | |||
| for x in mkd_line mkd_generateline; do \ | |||
| ( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\ | |||
| done | |||
| for x in mkd_in mkd_string; do \ | |||
| ( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\ | |||
| done | |||
| for x in mkd_compile mkd_css mkd_generatecss mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \ | |||
| ( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3; \ | |||
| done | |||
| @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man7 | |||
| @INSTALL_DATA@ markdown.7 mkd-extensions.7 $(DESTDIR)/$(MANDIR)/man7 | |||
| @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1 | |||
| @INSTALL_DATA@ markdown.1 $(DESTDIR)/$(MANDIR)/man1 | |||
| install.everything: install install.man | |||
| version.o: version.c VERSION | |||
| $(CC) -DVERSION=\"`cat VERSION`\" -c version.c | |||
| markdown: main.o $(MKDLIB) | |||
| $(CC) -o markdown main.o -lmarkdown @LIBS@ | |||
| # example programs | |||
| @THEME@theme: theme.o $(MKDLIB) mkdio.h | |||
| @THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@ | |||
| mkd2html: mkd2html.o $(MKDLIB) mkdio.h | |||
| $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@ | |||
| makepage: makepage.c $(MKDLIB) mkdio.h | |||
| $(CC) -o makepage makepage.c -lmarkdown @LIBS@ | |||
| main.o: main.c mkdio.h config.h | |||
| $(CC) -I. -c main.c | |||
| $(MKDLIB): $(OBJS) | |||
| $(AR) crv $(MKDLIB) $(OBJS) | |||
| $(RANLIB) $(MKDLIB) | |||
| test: $(PGMS) echo cols | |||
| @for x in tests/*.t; do \ | |||
| sh $$x || exit 1; \ | |||
| done | |||
| cols: tools/cols.c | |||
| $(CC) -o cols tools/cols.c | |||
| echo: tools/echo.c | |||
| $(CC) -o echo tools/echo.c | |||
| clean: | |||
| rm -f $(PGMS) $(SAMPLE_PGMS) *.o $(MKDLIB) | |||
| distclean spotless: clean | |||
| rm -f @GENERATED_FILES@ @CONFIGURE_FILES@ | |||
| markdown.o: markdown.c config.h cstring.h markdown.h | |||
| generate.o: generate.c config.h cstring.h markdown.h | |||
| dumptree.o: dumptree.c cstring.h markdown.h | |||
| mkdio.o: mkdio.c mkdio.h cstring.h config.h | |||
| xmlpage.o: xmlpage.c mkdio.h cstring.h config.h | |||
| toc.o: toc.c mkdio.h cstring.h config.h | |||
| @ -0,0 +1,40 @@ | |||
| % Discount on Plan 9 | |||
| % Josh Wood | |||
| % 2009-06-12 | |||
| # *Discount* Markdown compiler on Plan 9 | |||
| ## Build | |||
| % CONFIG='--enable-all-features' mk config | |||
| % mk install | |||
| % markdown -V | |||
| markdown: discount X.Y.Z DL_TAG HEADER DEBUG SUPERSCRIPT RELAXED DIV | |||
| `--enable-all-features` may be replaced by zero or more of: | |||
| --enable-dl-tag Use the DL tag extension | |||
| --enable-pandoc-header Use pandoc-style header blocks | |||
| --enable-superscript A^B becomes A<sup>B</sup> | |||
| --enable-amalloc Enable memory allocation debugging | |||
| --relaxed-emphasis underscores aren't special in the middle of words | |||
| --with-tabstops=N Set tabstops to N characters (default is 4) | |||
| --enable-div Enable >%id% divisions | |||
| --enable-alpha-list Enable (a)/(b)/(c) lists | |||
| --enable-all-features Turn on all stable optional features | |||
| ## Notes | |||
| The supplied mkfile merely drives Discount's own configure script and | |||
| then APE's *psh* environment to build the Discount source, then copies | |||
| the result(s) to locations appropriate for system-wide use on Plan 9. | |||
| There are a few other *mk*(1) targets: | |||
| `install.libs`: Discount includes a C library and header. | |||
| Installation is optional. Plan 9 binaries are statically linked. | |||
| `install.man`: Add manual pages for markdown(1) and (6). | |||
| `install.progs`: Extra programs. *makepage* writes complete XHTML | |||
| documents, rather than fragments. *mkd2html* is similar, but produces | |||
| HTML. | |||
| @ -0,0 +1,169 @@ | |||
| .TH MARKDOWN 1 | |||
| .SH NAME | |||
| markdown \- convert Markdown text to HTML | |||
| .SH SYNOPSIS | |||
| .B markdown | |||
| [ | |||
| .B -dTV | |||
| ] | |||
| [ | |||
| .BI -b " url-base | |||
| ] | |||
| [ | |||
| .BI -F " bitmap | |||
| ] | |||
| [ | |||
| .BI -f " flags | |||
| ] | |||
| [ | |||
| .BI -o " ofile | |||
| ] | |||
| [ | |||
| .BI -s " text | |||
| ] | |||
| [ | |||
| .BI -t " text | |||
| ] | |||
| [ | |||
| .I file | |||
| ] | |||
| .SH DESCRIPTION | |||
| The | |||
| .I markdown | |||
| utility reads the | |||
| .IR Markdown (6)-formatted | |||
| .I file | |||
| (or standard input) and writes its | |||
| .SM HTML | |||
| fragment representation on standard output. | |||
| .PP | |||
| The options are: | |||
| .TF dfdoptions | |||
| .TP | |||
| .BI -b " url-base | |||
| Links in source begining with | |||
| .B / | |||
| will be prefixed with | |||
| .I url-base | |||
| in the output. | |||
| .TP | |||
| .B -d | |||
| Instead of printing an | |||
| .SM HTML | |||
| fragment, print a parse tree. | |||
| .TP | |||
| .BI -F " bitmap | |||
| Set translation flags. | |||
| .I Bitmap | |||
| is a bit map of the various configuration options described in | |||
| .IR markdown (2). | |||
| .TP | |||
| .BI -f " flags | |||
| Set or clear various translation | |||
| .IR flags , | |||
| described below. | |||
| .I Flags | |||
| are in a comma-delimited list, with an optional | |||
| .B + | |||
| (set) prefix on each flag. | |||
| .TP | |||
| .BI -o " ofile | |||
| Write the generated | |||
| .SM HTML | |||
| to | |||
| .IR ofile . | |||
| .TP | |||
| .BI -s " text | |||
| Use the | |||
| .IR markdown (2) | |||
| function to format the | |||
| .I text | |||
| on standard input. | |||
| .TP | |||
| .B -T | |||
| Under | |||
| .B -f | |||
| .BR toc , | |||
| print the table of contents as an unordered list before the usual | |||
| .SM HTML | |||
| output. | |||
| .TP | |||
| .BI -t " text | |||
| Use | |||
| .IR mkd_text | |||
| (in | |||
| .IR markdown (2)) | |||
| to format | |||
| .I text | |||
| instead of processing standard input with | |||
| .IR markdown . | |||
| .TP | |||
| .B -V | |||
| Show version number and configuration. If the version includes the string | |||
| .BR DL_TAG , | |||
| .I markdown | |||
| was configured with definition list support. If the version includes the string | |||
| .BR HEADER , | |||
| .I markdown | |||
| was configured to support pandoc header blocks. | |||
| .PD | |||
| .SS TRANSLATION FLAGS | |||
| The translation flags understood by | |||
| .B -f | |||
| are: | |||
| .TF \ noheader | |||
| .TP | |||
| .B noimage | |||
| Don't allow image tags. | |||
| .TP | |||
| .B nolinks | |||
| Don't allow links. | |||
| .TP | |||
| .B nohtml | |||
| Don't allow any embedded HTML. | |||
| .TP | |||
| .B cdata | |||
| Generate valid XML output. | |||
| .TP | |||
| .B noheader | |||
| Do not process pandoc headers. | |||
| .TP | |||
| .B notables | |||
| Do not process the syntax extension for tables. | |||
| .TP | |||
| .B tabstops | |||
| Use Markdown-standard 4-space tabstops. | |||
| .TP | |||
| .B strict | |||
| Disable superscript and relaxed emphasis. | |||
| .TP | |||
| .B relax | |||
| Enable superscript and relaxed emphasis (the default). | |||
| .TP | |||
| .B toc | |||
| Enable table of contents support, generated from headings (in | |||
| .IR markdown (6)) | |||
| in the source. | |||
| .TP | |||
| .B 1.0 | |||
| Revert to Markdown 1.0 compatibility. | |||
| .PD | |||
| .PP | |||
| For example, | |||
| .B -f nolinks,quot | |||
| tells | |||
| .I markdown | |||
| not to allow | |||
| .B <a> | |||
| tags, and to expand double quotes. | |||
| .SH SOURCE | |||
| .B /sys/src/cmd/discount | |||
| .SH SEE ALSO | |||
| .IR markdown (2), | |||
| .IR markdown (6) | |||
| .PP | |||
| http://daringfireball.net/projects/markdown/, | |||
| ``Markdown''. | |||
| .SH DIAGNOSTICS | |||
| .I Markdown | |||
| exits 0 on success and >0 if an error occurs. | |||
| @ -0,0 +1,332 @@ | |||
| .TH MARKDOWN 2 | |||
| .SH NAME | |||
| mkd_in, mkd_string, markdown, mkd_compile, mkd_css, mkd_generatecss, | |||
| mkd_document, mkd_generatehtml, mkd_xhtmlpage, mkd_toc, mkd_generatetoc, | |||
| mkd_cleanup, mkd_doc_title, mkd_doc_author, mkd_doc_date, mkd_line, | |||
| mkd_generateline \- convert Markdown text to HTML | |||
| .SH SYNOPSIS | |||
| .ta \w'MMIOT* 'u | |||
| .B #include <mkdio.h> | |||
| .PP | |||
| .B | |||
| MMIOT* mkd_in(FILE *input) | |||
| .PP | |||
| .B | |||
| MMIOT* mkd_string(char *string, int size) | |||
| .PP | |||
| .B | |||
| int markdown(MMIOT *doc, FILE *output, int flags) | |||
| .PP | |||
| .B | |||
| int mkd_compile(MMIOT *document, int flags) | |||
| .PP | |||
| .B | |||
| int mkd_css(MMIOT *document, char **doc) | |||
| .PP | |||
| .B | |||
| int mkd_generatecss(MMIOT *document, FILE *output) | |||
| .PP | |||
| .B | |||
| int mkd_document(MMIOT *document, char **doc) | |||
| .PP | |||
| .B | |||
| int mkd_generatehtml(MMIOT *document, FILE *output) | |||
| .PP | |||
| .B | |||
| int mkd_xhtmlpage(MMIOT *document, int flags, FILE *output) | |||
| .PP | |||
| .B | |||
| int mkd_toc(MMIOT *document, char **doc) | |||
| .PP | |||
| .B | |||
| void mkd_generatetoc(MMIOT *document, FILE *output) | |||
| .PP | |||
| .B | |||
| void mkd_cleanup(MMIOT*); | |||
| .PP | |||
| .B | |||
| char* mkd_doc_title(MMIOT*) | |||
| .PP | |||
| .B | |||
| char* mkd_doc_author(MMIOT*) | |||
| .PP | |||
| .B | |||
| char* mkd_doc_date(MMIOT*) | |||
| .PP | |||
| .B | |||
| int mkd_line(char *string, int size, char **doc, int flags) | |||
| .PP | |||
| .B | |||
| int mkd_generateline(char *string, int size, FILE *output, int flags) | |||
| .PD | |||
| .PP | |||
| .SH DESCRIPTION | |||
| These functions convert | |||
| .IR Markdown (6) | |||
| text into | |||
| .SM HTML | |||
| markup. | |||
| .PP | |||
| .I Mkd_in | |||
| reads the text referenced by pointer to | |||
| .B FILE | |||
| .I input | |||
| and returns a pointer to an | |||
| .B MMIOT | |||
| structure of the form expected by | |||
| .I markdown | |||
| and the other converters. | |||
| .I Mkd_string | |||
| accepts one | |||
| .I string | |||
| and returns a pointer to | |||
| .BR MMIOT . | |||
| .PP | |||
| After such preparation, | |||
| .I markdown | |||
| converts | |||
| .I doc | |||
| and writes the result to | |||
| .IR output , | |||
| while | |||
| .I mkd_compile | |||
| transforms | |||
| .I document | |||
| in-place. | |||
| .PP | |||
| One or more of the following | |||
| .I flags | |||
| (combined with | |||
| .BR OR ) | |||
| control | |||
| .IR markdown 's | |||
| processing of | |||
| .IR doc : | |||
| .TF MKD_NOIMAGE | |||
| .TP | |||
| .B MKD_NOIMAGE | |||
| Do not process | |||
| .B ![] | |||
| and remove | |||
| .B <img> | |||
| tags from the output. | |||
| .TP | |||
| .B MKD_NOLINKS | |||
| Do not process | |||
| .B [] | |||
| and remove | |||
| .B <a> | |||
| tags from the output. | |||
| .TP | |||
| .B MKD_NOPANTS | |||
| Suppress Smartypants-style replacement of quotes, dashes, or ellipses. | |||
| .TP | |||
| .B MKD_STRICT | |||
| Disable superscript and relaxed emphasis processing if configured; otherwise a no-op. | |||
| .TP | |||
| .B MKD_TAGTEXT | |||
| Process as inside an | |||
| .SM HTML | |||
| tag: no | |||
| .BR <em> , | |||
| no | |||
| .BR <bold> , | |||
| no | |||
| .SM HTML | |||
| or | |||
| .B [] | |||
| expansion. | |||
| .TP | |||
| .B MKD_NO_EXT | |||
| Don't process pseudo-protocols (in | |||
| .IR markdown (6)). | |||
| .TP | |||
| .B MKD_CDATA | |||
| Generate code for | |||
| .SM XML | |||
| .B ![CDATA[...]] | |||
| element. | |||
| .TP | |||
| .B MKD_NOHEADER | |||
| Don't process Pandoc-style headers. | |||
| .TP | |||
| .B MKD_TABSTOP | |||
| When reading documents, expand tabs to 4 spaces, overriding any compile-time configuration. | |||
| .TP | |||
| .B MKD_TOC | |||
| Label headings for use with the | |||
| .I mkd_generatetoc | |||
| and | |||
| .I mkd_toc | |||
| functions. | |||
| .TP | |||
| .B MKD_1_COMPAT | |||
| MarkdownTest_1.0 compatibility. Trim trailing spaces from first line of code blocks and disable implicit reference links (in | |||
| .IR markdown (6)). | |||
| .TP | |||
| .B MKD_AUTOLINK | |||
| Greedy | |||
| .SM URL | |||
| generation. When set, any | |||
| .SM URL | |||
| is converted to a hyperlink, even those not encased in | |||
| .BR <> . | |||
| .TP | |||
| .B MKD_SAFELINK | |||
| Don't make hyperlinks from | |||
| .B [][] | |||
| links that have unknown | |||
| .SM URL | |||
| protocol types. | |||
| .TP | |||
| .B MKD_NOTABLES | |||
| Do not process the syntax extension for tables (in | |||
| .IR markdown (6)). | |||
| .TP | |||
| .B MKD_EMBED | |||
| All of | |||
| .BR MKD_NOLINKS , | |||
| .BR MKD_NOIMAGE , | |||
| and | |||
| .BR MKD_TAGTEXT . | |||
| .PD | |||
| .PP | |||
| This implementation supports | |||
| Pandoc-style | |||
| headers and inline | |||
| .SM CSS | |||
| .B <style> | |||
| blocks, but | |||
| .I markdown | |||
| does not access the data provided by these extensions. | |||
| The following functions do, and allow other manipulations. | |||
| .PP | |||
| Given a pointer to | |||
| .B MMIOT | |||
| prepared by | |||
| .I mkd_in | |||
| or | |||
| .IR mkd_string , | |||
| .I mkd_compile | |||
| compiles the | |||
| .I document | |||
| into | |||
| .BR <style> , | |||
| Pandoc, and | |||
| .SM HTML | |||
| sections. It accepts the | |||
| .I flags | |||
| described for | |||
| .IR markdown , | |||
| above. | |||
| .PP | |||
| Once compiled, the document particulars can be read and written: | |||
| .PP | |||
| .I Mkd_css | |||
| allocates a string and populates it with any | |||
| .B <style> | |||
| sections from the document. | |||
| .I Mkd_generatecss | |||
| writes any | |||
| .B <style> | |||
| sections to | |||
| .IR output . | |||
| .PP | |||
| .I Mkd_document | |||
| points | |||
| .I doc | |||
| to the | |||
| .B MMIOT | |||
| .IR document , | |||
| returning | |||
| .IR document 's | |||
| size. | |||
| .PP | |||
| .I Mkd_generatehtml | |||
| writes the rest of the | |||
| .I document | |||
| to the | |||
| .IR output . | |||
| .PP | |||
| .IR Mkd_doc_title , | |||
| .IR mkd_doc_author , | |||
| and | |||
| .I mkd_doc_date | |||
| read the contents of any Pandoc header. | |||
| .PP | |||
| .I Mkd_xhtmlpage | |||
| writes an | |||
| .SM XHTML | |||
| page representation of the document. | |||
| It accepts the | |||
| .I flags | |||
| described for | |||
| .IR markdown , | |||
| above. | |||
| .PP | |||
| .I Mkd_toc | |||
| .IR malloc s | |||
| a buffer into which it writes an outline, in the form of a | |||
| .B <ul> | |||
| element populated with | |||
| .BR <li> s | |||
| each containing a link to successive headings in the | |||
| .IR document . | |||
| It returns the size of that string. | |||
| .I Mkd_generatetoc | |||
| is similar, | |||
| but writes the outline to the | |||
| .I output | |||
| referenced by a pointer to | |||
| .BR FILE . | |||
| .PP | |||
| .I Mkd_cleanup | |||
| deletes a processed | |||
| .BR MMIOT . | |||
| .PP | |||
| The last two functions convert a single line of markdown source, for example a page title or a signature. | |||
| .I Mkd_line | |||
| allocates a buffer into which it writes an | |||
| .SM HTML | |||
| fragment representation of the | |||
| .IR string . | |||
| .I Mkd_generateline | |||
| writes the result to | |||
| .IR output . | |||
| .SH SOURCE | |||
| .B /sys/src/cmd/discount | |||
| .SH SEE ALSO | |||
| .IR markdown (1), | |||
| .IR markdown (6) | |||
| .SH DIAGNOSTICS | |||
| The | |||
| .I mkd_in | |||
| and | |||
| .I mkd_string | |||
| functions return a pointer to | |||
| .B MMIOT | |||
| on success, null on failure. | |||
| .IR Markdown , | |||
| .IR mkd_compile , | |||
| .IR mkd_style , | |||
| and | |||
| .I mkd_generatehtml | |||
| return | |||
| .B 0 | |||
| on success, | |||
| .B -1 | |||
| otherwise. | |||
| .SH BUGS | |||
| Error handling is minimal at best. | |||
| .PP | |||
| The | |||
| .B MMIOT | |||
| created by | |||
| .I mkd_string | |||
| is deleted by the | |||
| .I markdown | |||
| function. | |||
| .PP | |||
| This is an | |||
| .SM APE | |||
| library. | |||
| @ -0,0 +1,543 @@ | |||
| .TH MARKDOWN 6 | |||
| .SH NAME | |||
| Markdown \- text formatting syntax | |||
| .SH DESCRIPTION | |||
| Markdown | |||
| is a text markup syntax for machine conversion to | |||
| the more complex | |||
| .SM HTML | |||
| or | |||
| .SM XHTML | |||
| markup languages. | |||
| It is intended to be easy to read and to write, with | |||
| emphasis on readability. | |||
| A Markdown-formatted document should be publishable as-is, | |||
| in plain text, without the formatting distracting the reader. | |||
| .PP | |||
| The biggest source of inspiration for Markdown's | |||
| syntax is the format of plain text email. The markup is comprised entirely | |||
| of punctuation characters, chosen so as to look like what they mean. | |||
| Asterisks around a word look like | |||
| .IR *emphasis* . | |||
| Markdown lists look like lists. Even | |||
| blockquotes look like quoted passages of text, assuming the reader has | |||
| used email. | |||
| .PP | |||
| .SS Block Elements | |||
| .TF W | |||
| .PD | |||
| .TP | |||
| Paragraphs and Line Breaks | |||
| A paragraph is one or more consecutive lines of text, separated | |||
| by one or more blank lines. (A blank line is any line that looks like a | |||
| blank line -- a line containing nothing but spaces or tabs is considered | |||
| blank.) Normal paragraphs should not be indented with spaces or tabs. | |||
| .IP | |||
| Lines may be freely broken for readability; Markdown | |||
| does not translate source line breaks to | |||
| .B <br /> | |||
| tags. To request generation of | |||
| .B <br /> | |||
| in the output, end a line with two or more spaces, then a newline. | |||
| .TP | |||
| Headings | |||
| Headings can be marked in two ways, called | |||
| .I setext | |||
| and | |||
| .IR atx . | |||
| .IP | |||
| Setext-style headings are | |||
| ``underlined'' using equal signs (for first-level | |||
| headings) and dashes (for second-level headings). | |||
| .IP | |||
| Atx-style headings use 1-6 hash characters at the start of the line, | |||
| corresponding to | |||
| .SM HTML | |||
| .BR <h^(1-6)^> . | |||
| Optional closing hashes may follow | |||
| the heading text. | |||
| .TP | |||
| Blockquotes | |||
| Lines beginning with | |||
| .B > | |||
| are output in blockquotes. | |||
| Blockquotes can be nested | |||
| by multiple levels of | |||
| .BR >> . | |||
| Blockquotes can contain other Markdown elements, including | |||
| headings, lists, and code blocks. | |||
| .TP | |||
| Lists | |||
| Markdown supports ordered (numbered) and unordered (bulleted) lists. | |||
| List markers typically start at the left margin, but may be indented by | |||
| up to three spaces. | |||
| List markers must be followed by one or more spaces | |||
| or a tab, then the list item text. | |||
| A newline terminates each list item. | |||
| .IP | |||
| Unordered lists use asterisks, pluses, and hyphens interchangeably as | |||
| list markers. | |||
| .IP | |||
| Ordered lists use integers followed by periods as list markers. | |||
| The order of the integers is not interpreted, | |||
| but the list should begin with | |||
| .BR 1 . | |||
| .IP | |||
| If list items are separated by blank lines, Markdown will wrap each list | |||
| item in | |||
| .B <p> | |||
| tags in the | |||
| .SM HTML | |||
| output. | |||
| .IP | |||
| List items may consist of multiple paragraphs. | |||
| Each subsequent | |||
| paragraph within a list item must be indented by either 4 spaces | |||
| or one tab. | |||
| To put a blockquote within a list item, the blockquote's | |||
| .B > | |||
| marker needs to be indented. | |||
| To put a code block within a list item, the code block needs | |||
| to be indented | |||
| .I twice | |||
| -- 8 spaces or two tabs. | |||
| .TP | |||
| Code Blocks | |||
| To produce a code block, indent every line of the | |||
| block by at least 4 spaces or 1 tab. | |||
| A code block continues until it reaches a line that is not indented. | |||
| .IP | |||
| Rather than forming normal paragraphs, the lines | |||
| of a code block are interpreted literally. | |||
| Regular Markdown syntax is not processed within code blocks. | |||
| Markdown wraps a code block in both | |||
| .B <pre> | |||
| and | |||
| .B <code> | |||
| tags. | |||
| One level of indentation -- 4 | |||
| spaces or 1 tab -- is removed from each line of the code block in | |||
| the output. | |||
| .TP | |||
| Horizontal Rules | |||
| Produce a horizontal rule tag | |||
| .RB ( <hr\ /> ) | |||
| by placing three or | |||
| more hyphens, asterisks, or underscores on a line by themselves. | |||
| .SS Span Elements | |||
| .TF W | |||
| .PD | |||
| .TP | |||
| Links | |||
| Markdown supports two styles of links: | |||
| .I inline | |||
| and | |||
| .IR reference . | |||
| In both styles, the link text is delimited by square brackets | |||
| .RB ( [] ). | |||
| To create an inline link, use a set of regular parentheses immediately | |||
| after the link text's closing square bracket. | |||
| Inside the parentheses, | |||
| put the link URL, along with an optional | |||
| title for the link surrounded in double quotes. | |||
| For example: | |||
| .IP | |||
| .EX | |||
| An [example](http://example.com/ "Title") inline link. | |||
| .EE | |||
| .IP | |||
| Reference-style links use a second set of square brackets, inside | |||
| which you place a label of your choosing to identify the link: | |||
| .IP | |||
| .EX | |||
| An [example][id] reference-style link. | |||
| .EE | |||
| .IP | |||
| The label is then assigned a value on its own line, anywhere in the document: | |||
| .IP | |||
| .EX | |||
| [id]: http://example.com/ "Optional Title" | |||
| .EE | |||
| .IP | |||
| Link label names may consist of letters, numbers, spaces, and | |||
| punctuation. | |||
| Labels are not case sensitive. | |||
| An empty label bracket | |||
| set after a reference-style link implies the link label is equivalent to | |||
| the link text. | |||
| A URL value can then be assigned to the link by referencing | |||
| the link text as the label name. | |||
| .TP | |||
| Emphasis | |||
| Markdown treats asterisks | |||
| .RB ( * ) | |||
| and underscores | |||
| .RB ( _ ) | |||
| as indicators of emphasis. | |||
| Text surrounded with single asterisks or underscores | |||
| will be wrapped with an | |||
| .SM HTML | |||
| .B <em> | |||
| tag. | |||
| Double asterisks or underscores generate an | |||
| .SM HTML | |||
| .B <strong> | |||
| tag. | |||
| .TP | |||
| Code | |||
| To indicate a span of code, wrap it with backtick quotes | |||
| .RB ( ` ). | |||
| Unlike a code block, a code span indicates code within a | |||
| normal paragraph. | |||
| To include a literal backtick character within a code span, you can use | |||
| multiple backticks as the opening and closing delimiters: | |||
| .IP | |||
| .EX | |||
| ``There is a literal backtick (`) here.`` | |||
| .EE | |||
| .TP | |||
| Images | |||
| Markdown image syntax is intended to resemble that | |||
| for links, allowing for two styles, once again | |||
| .I inline | |||
| and | |||
| .IR reference . | |||
| The syntax is as for each respective style of link, described above, but | |||
| prefixed with an exclamation mark character | |||
| .RB ( ! ). | |||
| Inline image syntax looks like this: | |||
| .IP | |||
| .EX | |||
|  | |||
| .EE | |||
| .IP | |||
| That is: | |||
| An exclamation mark; | |||
| followed by a set of square brackets containing the `alt' | |||
| attribute text for the image; | |||
| followed by a set of parentheses containing the URL or path to | |||
| the image, and an optional `title' attribute enclosed in double | |||
| or single quotes. | |||
| .IP | |||
| Reference-style image syntax looks like this: | |||
| .IP | |||
| .EX | |||
| ![Alt text][id] | |||
| .EE | |||
| .IP | |||
| Where | |||
| .I id | |||
| is a label used as for reference-style URL links, described above. | |||
| .SS Convenience | |||
| .TF W | |||
| .PD | |||
| .TP | |||
| Automatic Links | |||
| There is a shortcut style for creating ``automatic'' | |||
| links for URLs and email addresses. | |||
| Surround the URL | |||
| or address with angle brackets. | |||
| .TP | |||
| Backslash Escapes | |||
| Use backslash escapes to generate literal | |||
| characters which would otherwise have special meaning in Markdown's | |||
| formatting syntax. | |||
| .TP | |||
| Inline HTML | |||
| For markup that is not covered by Markdown's | |||
| syntax, simply use the | |||
| .SM HTML | |||
| directly. | |||
| The only restrictions are that block-level | |||
| .SM HTML | |||
| elements -- | |||
| .BR <div> , | |||
| .BR <table> , | |||
| .BR <pre> , | |||
| .BR <p> , | |||
| etc. -- must be separated from surrounding | |||
| content by blank lines, and the start and end tags of the block should | |||
| not be indented with tabs or spaces. Markdown formatting syntax is | |||
| not processed within block-level | |||
| .SM HTML | |||
| tags. | |||
| .IP | |||
| Span-level | |||
| .SM HTML | |||
| tags -- e.g. | |||
| .BR <span> , | |||
| .BR <cite> , | |||
| or | |||
| .B <del> | |||
| -- can be | |||
| used anywhere in a Markdown | |||
| paragraph, list item, or heading. | |||
| It is permitted to use | |||
| .SM HTML | |||
| tags instead of Markdown formatting; e.g. | |||
| .SM HTML | |||
| .B <a> | |||
| or | |||
| .B <img> | |||
| tags instead of Markdown's | |||
| link or image syntax. | |||
| Unlike block-level | |||
| .SM HTML | |||
| tags, Markdown | |||
| syntax | |||
| .I is | |||
| processed within the elements of span-level tags. | |||
| .TP | |||
| Automatic Special Character Escapes | |||
| To be displayed literally in a user agent, the characters | |||
| .B < | |||
| and | |||
| .B & | |||
| must appear as escaped entities in | |||
| .SM HTML | |||
| source, e.g. | |||
| .B < | |||
| and | |||
| .BR & . | |||
| Markdown | |||
| allows natural use of these characters, taking care of | |||
| the necessary escaping. | |||
| The ampersand part of a directly-used | |||
| .SM HTML | |||
| entity remains unchanged; otherwise it will be translated | |||
| into | |||
| .BR & . | |||
| Inside code spans and blocks, angle brackets and | |||
| ampersands are always encoded automatically. | |||
| This makes it easy to use Markdown to write about | |||
| .SM HTML | |||
| code. | |||
| .PP | |||
| .SS Smarty Pants | |||
| The | |||
| .IR markdown (1) | |||
| utility transforms a few plain text symbols into their typographically-fancier | |||
| .SM HTML | |||
| entity equivalents. | |||
| These are extensions to the standard Markdown syntax. | |||
| .TF W | |||
| .PD | |||
| .TP | |||
| Punctuation | |||
| Input single- and double-quotes are transformed | |||
| into ``curly'' quote entities in the output (e.g., | |||
| .B 'text' | |||
| becomes | |||
| .BR ‘text’ ). | |||
| Input double-dashes | |||
| .RB ( -- ) | |||
| and triple-dashes become en- and em-dashes, respectively, | |||
| while a series of three dots | |||
| .RB ( ... ) | |||
| in the input becomes an ellipsis entity | |||
| .RB ( … ) | |||
| in the | |||
| .SM HTML | |||
| output. | |||
| .TP | |||
| Symbols | |||
| Three other transformations replace the common plain-text shorthands | |||
| .BR (c) , | |||
| .BR (r) , | |||
| and | |||
| .BR (tm) | |||
| from the input with their respective | |||
| .SM HTML | |||
| entities. (As in | |||
| .B (c) | |||
| becoming | |||
| .BR © , | |||
| the Copyright symbol entity.) | |||
| .TP | |||
| Fractions | |||
| A small set of plain-text shorthands for fractions is recognized. | |||
| .B 1/4 | |||
| becomes | |||
| .BR ¼ , | |||
| for example. These fraction notations are replaced with their | |||
| .SM HTML | |||
| entity equivalents: | |||
| .BR 1/4 , | |||
| .BR 1/2 , | |||
| .BR 3/4 . | |||
| .B 1/4th | |||
| and | |||
| .B 3/4ths | |||
| are replaced with their entity and the indicated ordinal suffix letters. | |||
| .PP | |||
| Like the basic Markdown syntax, none of the ``Smarty Pants'' extensions are processed | |||
| inside code blocks or spans. | |||
| .PP | |||
| .SS Discount Extensions | |||
| .IR Markdown (1) | |||
| recognizes some extensions to the Markdown format, | |||
| many of them adopted or adapted from other Markdown | |||
| interpreters or document formatting systems. | |||
| .TF W | |||
| .PD | |||
| .TP | |||
| Pandoc Headers | |||
| If | |||
| .I markdown | |||
| was configured with | |||
| .BR --enable-pandoc-header , | |||
| the markdown source can have a 3-line Pandoc header in the format of | |||
| .IP | |||
| .EX | |||
| % Title | |||
| % Author | |||
| % Date | |||
| .EE | |||
| .IP | |||
| whose data is available to the | |||
| .IR mkd_doc_title , | |||
| .IR mkd_doc_author , | |||
| and | |||
| .I mkd_doc_date | |||
| (in | |||
| .IR markdown (2)) | |||
| functions. | |||
| .TP | |||
| Embedded Stylesheets | |||
| Stylesheets may be defined and modified in a | |||
| .B <style> | |||
| block. A style block is parsed like any other block-level | |||
| .SM HTML; | |||
| .B <style> | |||
| starting on column 1, raw | |||
| .SM HTML | |||
| (or, in this case, | |||
| .SM CSS \) | |||
| following it, and either ending with a | |||
| .B </style> | |||
| at the end of the line or at the beginning of a subsequent line. | |||
| .IP | |||
| Style blocks apply to the entire document regardless of where they are defined. | |||
| .TP | |||
| Image Dimensions | |||
| Image specification has been extended with an argument describing image dimensions: | |||
| .BI = height x width. | |||
| For an image 400 pixels high and 300 wide, the new syntax is: | |||
| .IP | |||
| .EX | |||
|  | |||
| .EE | |||
| .TP | |||
| Pseudo-Protocols | |||
| Pseudo-protocols that may replace the common | |||
| .B http: | |||
| or | |||
| .B mailto: | |||
| have been added to the link syntax described above. | |||
| .IP | |||
| .BR abbr : | |||
| Text following is used as the | |||
| .B title | |||
| attribute of an | |||
| .B abbr | |||
| tag wrapping the link text. So | |||
| .B [LT](abbr:Link Text) | |||
| gives | |||
| .B <abbr title="Link Text">LT</abbr>. | |||
| .IP | |||
| .BR id : | |||
| The link text is marked up and written to the output, wrapped with | |||
| .B <a id=text following> | |||
| and | |||
| .BR </a> . | |||
| .IP | |||
| .BR class : | |||
| The link text is marked up and written to the output, wrapped with | |||
| .B <span class=text following> | |||
| and | |||
| .BR </span> . | |||
| .IP | |||
| .BR raw : | |||
| Text following is written to the output with no further processing. | |||
| The link text is discarded. | |||
| .TP | |||
| Alphabetic Lists | |||
| If | |||
| .I markdown | |||
| was configured with | |||
| .BR --enable-alpha-list , | |||
| .IP | |||
| .EX | |||
| a. this | |||
| b. is | |||
| c. an alphabetic | |||
| d. list | |||
| .EE | |||
| .IP | |||
| yields an | |||
| .SM HTML | |||
| .B ol | |||
| ordered list. | |||
| .TP | |||
| Definition Lists | |||
| If configured with | |||
| .BR --enable-dl-tag , | |||
| markup for definition lists is enabled. A definition list item is defined as | |||
| .IP | |||
| .EX | |||
| =term= | |||
| definition | |||
| .EE | |||
| .TP | |||
| Tables | |||
| Tables are specified with a pipe | |||
| .RB ( | ) | |||
| and dash | |||
| .RB ( - ) | |||
| marking. The markdown text | |||
| .IP | |||
| .EX | |||
| header0|header1 | |||
| -------|------- | |||
| textA|textB | |||
| textC|textD | |||
| .EE | |||
| .IP | |||
| will produce an | |||
| .SM HTML | |||
| .B table | |||
| of two columns and three rows. | |||
| A header row is designated by ``underlining'' with dashes. | |||
| Declare a column's alignment by affixing a colon | |||
| .RB ( : ) | |||
| to the left or right end of the dashes underlining its header. | |||
| In the output, this | |||
| yields the corresponding value for the | |||
| .B align | |||
| attribute on each | |||
| .B td | |||
| cell in the column. | |||
| A colon at both ends of a column's header dashes indicates center alignment. | |||
| .TP | |||
| Relaxed Emphasis | |||
| If configured with | |||
| .BR --relaxed-emphasis , | |||
| the rules for emphasis are changed so that a single | |||
| .B _ | |||
| will not count as an emphasis character in the middle of a word. | |||
| This is useful for documenting some code where | |||
| .B _ | |||
| appears frequently, and would normally require a backslash escape. | |||
| .PD | |||
| .SH SEE ALSO | |||
| .IR markdown (1), | |||
| .IR markdown (2) | |||
| .PP | |||
| http://daringfireball.net/projects/markdown/syntax/, | |||
| ``Markdown: Syntax''. | |||
| .PP | |||
| http://daringfireball.net/projects/smartypants/, | |||
| ``Smarty Pants''. | |||
| .PP | |||
| http://michelf.com/projects/php-markdown/extra/#table, | |||
| ``PHP Markdown Extra: Tables''. | |||
| @ -0,0 +1,37 @@ | |||
| BIN=/$objtype/bin | |||
| CC='cc -D_BSD_EXTENSION' | |||
| markdown: | |||
| ape/psh -c 'cd .. && make' | |||
| none:V: markdown | |||
| test: markdown | |||
| ape/psh -c 'cd ..&& make test' | |||
| install: markdown | |||
| cp ../markdown $BIN/markdown | |||
| install.progs: install | |||
| cp ../makepage $BIN/makepage | |||
| cp ../mkd2html $BIN/mkd2html | |||
| install.libs: install | |||
| cp ../mkdio.h /sys/include/ape/mkdio.h | |||
| cp ../libmarkdown.a /$objtype/lib/ape/libmarkdown.a | |||
| install.man: install | |||
| cp markdown.1 /sys/man/1/markdown | |||
| cp markdown.2 /sys/man/2/markdown | |||
| cp markdown.6 /sys/man/6/markdown | |||
| installall:V: install.libs install.man install.progs | |||
| config: | |||
| ape/psh -c 'cd .. && ./configure.sh $CONFIG' | |||
| clean: | |||
| ape/psh -c 'cd .. && make clean' | |||
| nuke: | |||
| ape/psh -c 'cd .. && make distclean' | |||
| @ -0,0 +1 @@ | |||
| 1.5.5 | |||
| @ -0,0 +1,76 @@ | |||
| /* markdown: a C implementation of John Gruber's Markdown markup language. | |||
| * | |||
| * Copyright (C) 2009 David L Parsons. | |||
| * The redistribution terms are provided in the COPYRIGHT file that must | |||
| * be distributed with this source code. | |||
| */ | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include <stdarg.h> | |||
| #include <stdlib.h> | |||
| #include <time.h> | |||
| #include <ctype.h> | |||
| #include "config.h" | |||
| #include "cstring.h" | |||
| #include "markdown.h" | |||
| #include "amalloc.h" | |||
| /* | |||
| * dump out stylesheet sections. | |||
| */ | |||
| static void | |||
| stylesheets(Paragraph *p, Cstring *f) | |||
| { | |||
| Line* q; | |||
| for ( ; p ; p = p->next ) { | |||
| if ( p->typ == STYLE ) { | |||
| for ( q = p->text; q ; q = q->next ) | |||
| Cswrite(f, T(q->text), S(q->text)); | |||
| Csputc('\n', f); | |||
| } | |||
| if ( p->down ) | |||
| stylesheets(p->down, f); | |||
| } | |||
| } | |||
| /* dump any embedded styles to a string | |||
| */ | |||
| int | |||
| mkd_css(Document *d, char **res) | |||
| { | |||
| Cstring f; | |||
| if ( res && *res && d && d->compiled ) { | |||
| CREATE(f); | |||
| RESERVE(f, 100); | |||
| stylesheets(d->code, &f); | |||
| /* HACK ALERT! HACK ALERT! HACK ALERT! */ | |||
| *res = T(f); /* we know that a T(Cstring) is a character pointer */ | |||
| /* so we can simply pick it up and carry it away, */ | |||
| return S(f); /* leaving the husk of the Ctring on the stack */ | |||
| /* END HACK ALERT */ | |||
| } | |||
| return EOF; | |||
| } | |||
| /* dump any embedded styles to a file | |||
| */ | |||
| int | |||
| mkd_generatecss(Document *d, FILE *f) | |||
| { | |||
| char *res; | |||
| int written = EOF, size = mkd_css(d, &res); | |||
| if ( size > 0 ) | |||
| written = fwrite(res, size, 1, f); | |||
| if ( res ) | |||
| free(res); | |||
| return (written == size) ? size : EOF; | |||
| } | |||
| @ -0,0 +1,41 @@ | |||
| .\" | |||
| .Dd January 18, 2008 | |||
| .Dt MKD_LINE 3 | |||
| .Os Mastodon | |||
| .Sh NAME | |||
| .Nm mkd_line | |||
| .Nd do Markdown translation of small items | |||
| .Sh LIBRARY | |||
| Markdown | |||
| .Pq libmarkdown , -lmarkdown | |||
| .Sh SYNOPSIS | |||
| .Fd #include <mkdio.h> | |||
| .Ft int | |||
| .Fn mkd_line "char *string" "int size" "char **doc" "int flags" | |||
| .Ft int | |||
| .Fn mkd_generateline "char *string" "int size" "FILE *output" "int flags" | |||
| .Sh DESCRIPTION | |||
| .Pp | |||
| Occasionally one might want to do markdown translations on fragments of | |||
| data, like the title of an weblog article, a date, or a simple signature | |||
| line. | |||
| .Nm mkd_line | |||
| and | |||
| .Nm mkd_generateline | |||
| allow you to do markdown translations on small blocks of text. | |||
| .Nm mkd_line | |||
| allocates a buffer, then writes the translated text into that buffer, | |||
| and | |||
| .Nm mkd_generateline | |||
| writes the output to the specified | |||
| .Ar FILE* . | |||
| .Sh SEE ALSO | |||
| .Xr markdown 1 , | |||
| .Xr markdown 3 , | |||
| .Xr markdown 7 , | |||
| .Xr mkd-extensions 7 , | |||
| .Xr mmap 2 . | |||
| .Pp | |||
| http://daringfireball.net/projects/markdown/syntax | |||
| .Sh BUGS | |||
| Error handling is minimal at best. | |||
| @ -0,0 +1,42 @@ | |||
| ./echo 'Reddit-style automatic links' | |||
| rc=0 | |||
| 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 | |||
| } | |||
| try -fautolink 'single link' \ | |||
| 'http://www.pell.portland.or.us/~orc/Code/discount' \ | |||
| '<p><a href="http://www.pell.portland.or.us/~orc/Code/discount">http://www.pell.portland.or.us/~orc/Code/discount</a></p>' | |||
| try -fautolink 'link surrounded by text' \ | |||
| 'here http://it is?' \ | |||
| '<p>here <a href="http://it">http://it</a> is?</p>' | |||
| try -fautolink 'naked @' '@' '<p>@</p>' | |||
| try -fautolink 'parenthesised (url)' \ | |||
| '(http://here)' \ | |||
| '<p>(<a href="http://here">http://here</a>)</p>' | |||
| try -fautolink 'token with trailing @' 'orc@' '<p>orc@</p>' | |||
| exit $rc | |||
| @ -0,0 +1,53 @@ | |||
| ./echo "automatic links" | |||
| 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 | |||
| } | |||
| match() { | |||
| ./echo -n " $1" '..................................' | ./cols 36 | |||
| if ./echo "$2" | ./markdown | grep "$3" >/dev/null; then | |||
| ./echo " ok" | |||
| else | |||
| ./echo " FAILED" | |||
| rc=1 | |||
| fi | |||
| } | |||
| try 'http url' '<http://here>' '<p><a href="http://here">http://here</a></p>' | |||
| try 'ftp url' '<ftp://here>' '<p><a href="ftp://here">ftp://here</a></p>' | |||
| match '<orc@pell.portland.or.us>' '<orc@pell.portland.or.us>' '<a href=' | |||
| match '<orc@pell.com.>' '<orc@pell.com.>' '<a href=' | |||
| try 'invalid <orc@>' '<orc@>' '<p><orc@></p>' | |||
| try 'invalid <@pell>' '<@pell>' '<p><@pell></p>' | |||
| try 'invalid <orc@pell>' '<orc@pell>' '<p><orc@pell></p>' | |||
| try 'invalid <orc@.pell>' '<orc@.pell>' '<p><orc@.pell></p>' | |||
| try 'invalid <orc@pell.>' '<orc@pell.>' '<p><orc@pell.></p>' | |||
| match '<mailto:orc@pell>' '<mailto:orc@pell>' '<a href=' | |||
| match '<mailto:orc@pell.com>' '<mailto:orc@pell.com>' '<a href=' | |||
| match '<mailto:orc@>' '<mailto:orc@>' '<a href=' | |||
| match '<mailto:@pell>' '<mailto:@pell>' '<a href=' | |||
| exit $rc | |||
| @ -0,0 +1,35 @@ | |||
| ./echo "backslash escapes" | |||
| 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 | |||
| } | |||
| try 'backslashes in []()' '[foo](http://\this\is\.a\test\(here\))' \ | |||
| '<p><a href="http://\this\is.a\test(here)">foo</a></p>' | |||
| try -fautolink 'autolink url with trailing \' \ | |||
| 'http://a.com/\' \ | |||
| '<p><a href="http://a.com/\">http://a.com/\</a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,39 @@ | |||
| ./echo "code blocks" | |||
| 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 | |||
| } | |||
| try 'format for code block html' \ | |||
| ' this is | |||
| code' \ | |||
| '<pre><code>this is | |||
| code | |||
| </code></pre>' | |||
| try 'unclosed single backtick' '`hi there' '<p>`hi there</p>' | |||
| try 'unclosed double backtick' '``hi there' '<p>``hi there</p>' | |||
| try 'remove space around code' '`` hi there ``' '<p><code>hi there</code></p>' | |||
| exit $rc | |||
| @ -0,0 +1,47 @@ | |||
| ./echo "markdown 1.0 compatability" | |||
| 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' | |||
| 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" | |||
| try 'trailing whitespace' "$WHITESPACE" '<pre><code>white space '' | |||
| and more | |||
| </code></pre>' | |||
| try -f1.0 'trailing whitespace (-f1.0)' "$WHITESPACE" '<pre><code>white space'' | |||
| and more | |||
| </code></pre>' | |||
| exit $rc | |||
| @ -0,0 +1,67 @@ | |||
| ./markdown -V | grep DIV >/dev/null || exit 0 | |||
| ./echo "%div% blocks" | |||
| 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 | |||
| } | |||
| try 'simple >%div% block' \ | |||
| '>%this% | |||
| this this' \ | |||
| '<div class="this"><p>this this</p></div>' | |||
| try 'two >%div% blocks in a row' \ | |||
| '>%this% | |||
| this this | |||
| >%that% | |||
| that that' \ | |||
| '<div class="this"><p>this this</p></div> | |||
| <div class="that"><p>that that</p></div>' | |||
| try '>%class:div%' \ | |||
| '>%class:this% | |||
| this this' \ | |||
| '<div class="this"><p>this this</p></div>' | |||
| try '>%id:div%' \ | |||
| '>%id:this% | |||
| this this' \ | |||
| '<div id="this"><p>this this</p></div>' | |||
| try 'nested >%div%' \ | |||
| '>%this% | |||
| >>%that% | |||
| >>that | |||
| >%more% | |||
| more' \ | |||
| '<div class="this"><div class="that"><p>that</p></div></div> | |||
| <div class="more"><p>more</p></div>' | |||
| exit $rc | |||
| @ -0,0 +1,69 @@ | |||
| ./echo "definition lists" | |||
| 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 | |||
| } | |||
| SRC=' | |||
| =this= | |||
| is an ugly | |||
| =test= | |||
| eh?' | |||
| RSLT='<dl> | |||
| <dt>this</dt> | |||
| <dd>is an ugly</dd> | |||
| <dt>test</dt> | |||
| <dd>eh?</dd> | |||
| </dl>' | |||
| if ./markdown -V | grep DL_TAG >/dev/null; then | |||
| try '=tag= generates definition lists' "$SRC" "$RSLT" | |||
| try 'one item with two =tags=' \ | |||
| '=this= | |||
| =is= | |||
| A test, eh?' \ | |||
| '<dl> | |||
| <dt>this</dt> | |||
| <dt>is</dt> | |||
| <dd>A test, eh?</dd> | |||
| </dl>' | |||
| else | |||
| try '=tag= does nothing' "$SRC" \ | |||
| '<p>=this=</p> | |||
| <pre><code>is an ugly | |||
| </code></pre> | |||
| <p>=test=</p> | |||
| <pre><code>eh? | |||
| </code></pre>' | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,40 @@ | |||
| ./echo "emphasis" | |||
| 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 | |||
| } | |||
| 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 | |||
| 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 | |||
| @ -0,0 +1,52 @@ | |||
| ./echo "paragraph flow" | |||
| 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 | |||
| } | |||
| try 'header followed by paragraph' \ | |||
| '###Hello, sailor### | |||
| And how are you today?' \ | |||
| '<h3>Hello, sailor</h3> | |||
| <p>And how are you today?</p>' | |||
| try 'two lists punctuated with a HR' \ | |||
| '* A | |||
| * * * | |||
| * B | |||
| * C' \ | |||
| '<ul> | |||
| <li>A</li> | |||
| </ul> | |||
| <hr /> | |||
| <ul> | |||
| <li>B</li> | |||
| <li>C</li> | |||
| </ul>' | |||
| exit $rc | |||
| @ -0,0 +1,34 @@ | |||
| ./echo "footnotes" | |||
| 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 | |||
| } | |||
| try 'a line with multiple []s' '[a][] [b][]:' '<p>[a][] [b][]:</p>' | |||
| try 'a valid footnote' \ | |||
| '[alink][] | |||
| [alink]: link_me' \ | |||
| '<p><a href="link_me">alink</a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,109 @@ | |||
| ./echo "html blocks" | |||
| 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 | |||
| } | |||
| try 'self-closing block tags (hr)' \ | |||
| '<hr> | |||
| text' \ | |||
| '<hr> | |||
| <p>text</p>' | |||
| try 'self-closing block tags (hr/)' \ | |||
| '<hr/> | |||
| text' \ | |||
| '<hr/> | |||
| <p>text</p>' | |||
| try 'self-closing block tags (br)' \ | |||
| '<br> | |||
| text' \ | |||
| '<br> | |||
| <p>text</p>' | |||
| try 'html comments' \ | |||
| '<!-- | |||
| **hi** | |||
| -->' \ | |||
| '<!-- | |||
| **hi** | |||
| -->' | |||
| try 'no smartypants inside tags (#1)' \ | |||
| '<img src="linky">' \ | |||
| '<p><img src="linky"></p>' | |||
| try 'no smartypants inside tags (#2)' \ | |||
| '<img src="linky" alt=":)" />' \ | |||
| '<p><img src="linky" alt=":)" /></p>' | |||
| try -fnohtml 'block html with -fnohtml' '<b>hi!</b>' '<p><b>hi!</b></p>' | |||
| try -fhtml 'allow html with -fhtml' '<b>hi!</b>' '<p><b>hi!</b></p>' | |||
| # check that nested raw html blocks terminate properly. | |||
| # | |||
| BLOCK1SRC='Markdown works fine *here*. | |||
| *And* here. | |||
| <div><pre> | |||
| </pre></div> | |||
| Markdown here is *not* parsed by RDiscount. | |||
| Nor in *this* paragraph, and there are no paragraph breaks.' | |||
| BLOCK1OUT='<p>Markdown works fine <em>here</em>.</p> | |||
| <p><em>And</em> here.</p> | |||
| <div><pre> | |||
| </pre></div> | |||
| <p>Markdown here is <em>not</em> parsed by RDiscount.</p> | |||
| <p>Nor in <em>this</em> paragraph, and there are no paragraph breaks.</p>' | |||
| try 'nested html blocks (1)' "$BLOCK1SRC" "$BLOCK1OUT" | |||
| try 'nested html blocks (2)' \ | |||
| '<div>This is inside a html block | |||
| <div>This is, too</div>and | |||
| so is this</div>' \ | |||
| '<div>This is inside a html block | |||
| <div>This is, too</div>and | |||
| so is this</div>' | |||
| exit $rc | |||
| @ -0,0 +1,124 @@ | |||
| ./echo "embedded links" | |||
| 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 | |||
| } | |||
| try 'url contains &' '[hehehe](u&rl)' '<p><a href="u&rl">hehehe</a></p>' | |||
| try 'url contains +' '[hehehe](u+rl)' '<p><a href="u+rl">hehehe</a></p>' | |||
| try 'url contains "' '[hehehe](u"rl)' '<p><a href="u%22rl">hehehe</a></p>' | |||
| try 'url contains <' '[hehehe](u<rl)' '<p><a href="u<rl">hehehe</a></p>' | |||
| try 'url contains whitespace' '[ha](r u)' '<p><a href="r%20u">ha</a></p>' | |||
| try 'url contains whitespace & title' \ | |||
| '[hehehe](r u "there")' \ | |||
| '<p><a href="r%20u" title="there">hehehe</a></p>' | |||
| try 'url contains escaped )' \ | |||
| '[hehehe](u\))' \ | |||
| '<p><a href="u)">hehehe</a></p>' | |||
| try 'image label contains <' \ | |||
| '' \ | |||
| '<p><img src="url" alt="he<he<he" /></p>' | |||
| try 'image label contains >' \ | |||
| '' \ | |||
| '<p><img src="url" alt="he>he>he" /></p>' | |||
| try 'sloppy context link' \ | |||
| '[heh]( url "how about it?" )' \ | |||
| '<p><a href="url" title="how about it?">heh</a></p>' | |||
| try 'footnote urls formed properly' \ | |||
| '[hehehe]: hohoho "ha ha" | |||
| [hehehe][]' \ | |||
| '<p><a href="hohoho" title="ha ha">hehehe</a></p>' | |||
| try 'linky-like []s work' \ | |||
| '[foo]' \ | |||
| '<p>[foo]</p>' | |||
| try 'pseudo-protocol "id:"'\ | |||
| '[foo](id:bar)' \ | |||
| '<p><a id="bar">foo</a></p>' | |||
| try 'pseudo-protocol "class:"' \ | |||
| '[foo](class:bar)' \ | |||
| '<p><span class="bar">foo</span></p>' | |||
| try 'pseudo-protocol "abbr:"'\ | |||
| '[foo](abbr:bar)' \ | |||
| '<p><abbr title="bar">foo</abbr></p>' | |||
| try 'nested [][]s' \ | |||
| '[[z](y)](x)' \ | |||
| '<p><a href="x">[z](y)</a></p>' | |||
| try 'empty [][] tags' \ | |||
| '[![][1]][2] | |||
| [1]: image1 | |||
| [2]: image2' \ | |||
| '<p><a href="image2"><img src="image1" alt="" /></a></p>' | |||
| try 'footnote cuddled up to text' \ | |||
| 'foo | |||
| [bar]:bar' \ | |||
| '<p>foo</p>' | |||
| try 'mid-paragraph footnote' \ | |||
| 'talk talk talk talk | |||
| [bar]: bar | |||
| talk talk talk talk' \ | |||
| '<p>talk talk talk talk | |||
| talk talk talk talk</p>' | |||
| try 'mid-blockquote footnote' \ | |||
| '>blockquote! | |||
| [footnote]: here! | |||
| >blockquote!' \ | |||
| '<blockquote><p>blockquote! | |||
| blockquote!</p></blockquote>' | |||
| try 'end-blockquote footnote' \ | |||
| '>blockquote! | |||
| >blockquote! | |||
| [footnote]: here!' \ | |||
| '<blockquote><p>blockquote! | |||
| blockquote!</p></blockquote>' | |||
| try 'start-blockquote footnote' \ | |||
| '[footnote]: here! | |||
| >blockquote! | |||
| >blockquote!' \ | |||
| '<blockquote><p>blockquote! | |||
| blockquote!</p></blockquote>' | |||
| try '[text] (text) not a link' \ | |||
| '[test] (me)' \ | |||
| '<p>[test] (me)</p>' | |||
| exit $rc | |||
| @ -0,0 +1,31 @@ | |||
| ./echo "embedded images" | |||
| 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 | |||
| } | |||
| try 'image with size extension' \ | |||
| '' \ | |||
| '<p><img src="pic" height="200" width="200" alt="picture" /></p>' | |||
| exit $rc | |||
| @ -0,0 +1,168 @@ | |||
| ./echo "lists" | |||
| 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 | |||
| } | |||
| try 'two separated items' \ | |||
| ' * A | |||
| * B' \ | |||
| '<ul> | |||
| <li><p>A</p></li> | |||
| <li><p>B</p></li> | |||
| </ul>' | |||
| try 'two adjacent items' \ | |||
| ' * A | |||
| * B' \ | |||
| '<ul> | |||
| <li>A</li> | |||
| <li>B</li> | |||
| </ul>' | |||
| try 'two adjacent items, then space' \ | |||
| ' * A | |||
| * B | |||
| space, the final frontier' \ | |||
| '<ul> | |||
| <li>A</li> | |||
| <li>B</li> | |||
| </ul> | |||
| <p>space, the final frontier</p>' | |||
| try 'nested lists (1)' \ | |||
| ' * 1. Sub (list) | |||
| 2. Two (items) | |||
| 3. Here' \ | |||
| '<ul> | |||
| <li><ol> | |||
| <li>Sub (list)</li> | |||
| <li>Two (items)</li> | |||
| <li>Here</li> | |||
| </ol> | |||
| </li> | |||
| </ul>' | |||
| try 'nested lists (2)' \ | |||
| ' * A (list) | |||
| 1. Sub (list) | |||
| 2. Two (items) | |||
| 3. Here | |||
| Here | |||
| * B (list)' \ | |||
| '<ul> | |||
| <li><p>A (list)</p> | |||
| <ol> | |||
| <li>Sub (list)</li> | |||
| <li>Two (items)</li> | |||
| <li>Here</li> | |||
| </ol> | |||
| <p> Here</p></li> | |||
| <li>B (list)</li> | |||
| </ul>' | |||
| try 'list inside blockquote' \ | |||
| '>A (list) | |||
| > | |||
| >1. Sub (list) | |||
| >2. Two (items) | |||
| >3. Here' \ | |||
| '<blockquote><p>A (list)</p> | |||
| <ol> | |||
| <li>Sub (list)</li> | |||
| <li>Two (items)</li> | |||
| <li>Here</li> | |||
| </ol> | |||
| </blockquote>' | |||
| try 'blockquote inside list' \ | |||
| ' * A (list) | |||
| > quote | |||
| > me | |||
| dont quote me' \ | |||
| '<ul> | |||
| <li><p>A (list)</p> | |||
| <blockquote><p>quote | |||
| me</p></blockquote> | |||
| <p>dont quote me</p></li> | |||
| </ul>' | |||
| try 'empty list' \ | |||
| ' | |||
| - | |||
| - | |||
| ' \ | |||
| '<ul> | |||
| <li></li> | |||
| <li></li> | |||
| </ul>' | |||
| if ./markdown -V | grep DL_TAG >/dev/null; then | |||
| try 'dl followed by non-dl' \ | |||
| '=a= | |||
| test | |||
| 2. here' \ | |||
| '<dl> | |||
| <dt>a</dt> | |||
| <dd>test</dd> | |||
| </dl> | |||
| <ol> | |||
| <li>here</li> | |||
| </ol>' | |||
| try 'non-dl followed by dl' \ | |||
| '1. hello | |||
| =sailor= | |||
| hi!' \ | |||
| '<ol> | |||
| <li>hello</li> | |||
| </ol> | |||
| <dl> | |||
| <dt>sailor</dt> | |||
| <dd>hi!</dd> | |||
| </dl>' | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,57 @@ | |||
| ./echo "deeply nested lists" | |||
| 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 | |||
| } | |||
| LIST=' | |||
| * top-level list ( list 1) | |||
| + second-level list (list 2) | |||
| * first item third-level list (list 3) | |||
| + * second item, third-level list, first item. (list 4) | |||
| * second item, third-level list, second item. | |||
| * top-level list again.' | |||
| RSLT='<ul> | |||
| <li>top-level list ( list 1) | |||
| <ul> | |||
| <li>second-level list (list 2) | |||
| <ul> | |||
| <li>first item third-level list (list 3)</li> | |||
| </ul> | |||
| </li> | |||
| <li><ul> | |||
| <li>second item, third-level list, first item. (list 4)</li> | |||
| <li>second item, third-level list, second item.</li> | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <li>top-level list again.</li> | |||
| </ul>' | |||
| try 'thrice-nested lists' "$LIST" "$RSLT" | |||
| exit $rc | |||
| @ -0,0 +1,33 @@ | |||
| ./echo "misc" | |||
| 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 | |||
| } | |||
| try 'single paragraph' 'AAA' '<p>AAA</p>' | |||
| try '< -> <' '<' '<p><</p>' | |||
| try '`>` -> <code>></code>' '`>`' '<p><code>></code></p>' | |||
| try '`` ` `` -> <code>`</code>' '`` ` ``' '<p><code>`</code></p>' | |||
| exit $rc | |||
| @ -0,0 +1,74 @@ | |||
| ./echo "pandoc headers" | |||
| 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 | |||
| } | |||
| HEADER='% title | |||
| % author(s) | |||
| % date' | |||
| if ./markdown -V | grep HEADER > /dev/null; then | |||
| try 'valid header' "$HEADER" '' | |||
| try -F0x0100 'valid header with -F0x0100' "$HEADER" '<p>% title | |||
| % author(s) | |||
| % date</p>' | |||
| try 'invalid header' \ | |||
| '% title | |||
| % author(s) | |||
| a pony!' \ | |||
| '<p>% title | |||
| % author(s) | |||
| a pony!</p>' | |||
| try 'offset header' \ | |||
| ' | |||
| % title | |||
| % author(s) | |||
| % date' \ | |||
| '<p>% title | |||
| % author(s) | |||
| % date</p>' | |||
| try 'indented header' \ | |||
| ' % title | |||
| % author(s) | |||
| % date' \ | |||
| '<p> % title | |||
| % author(s) | |||
| % date</p>' | |||
| else | |||
| try 'ignore headers' "$HEADER" '<p>% title | |||
| % author(s) | |||
| % date</p>' | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,38 @@ | |||
| ./echo "paragraph blocking" | |||
| 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 | |||
| } | |||
| try 'paragraph followed by code' \ | |||
| 'a | |||
| b' \ | |||
| '<p>a</p> | |||
| <pre><code>b | |||
| </code></pre>' | |||
| try 'single-line paragraph' 'a' '<p>a</p>' | |||
| exit $rc | |||
| @ -0,0 +1,31 @@ | |||
| ./echo "paranoia" | |||
| 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 | |||
| } | |||
| try -fsafelink 'bogus url (-fsafelink)' '[test](bad:protocol)' '<p>[test](bad:protocol)</p>' | |||
| try -fnosafelink 'bogus url (-fnosafelink)' '[test](bad:protocol)' '<p><a href="bad:protocol">test</a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,64 @@ | |||
| ./echo "markup peculiarities" | |||
| 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 | |||
| } | |||
| try 'list followed by header .......... ' \ | |||
| " | |||
| - AAA | |||
| - BBB | |||
| -" \ | |||
| '<ul> | |||
| <li>AAA | |||
| <h2>– BBB</h2></li> | |||
| </ul>' | |||
| try 'ul with mixed item prefixes' \ | |||
| ' | |||
| - A | |||
| 1. B' \ | |||
| '<ul> | |||
| <li>A</li> | |||
| <li>B</li> | |||
| </ul>' | |||
| try 'ol with mixed item prefixes' \ | |||
| ' | |||
| 1. A | |||
| - B | |||
| ' \ | |||
| '<ol> | |||
| <li>A</li> | |||
| <li>B</li> | |||
| </ol>' | |||
| try 'forcing a <br/>' 'this ' '<p>this<br/> | |||
| </p>' | |||
| try 'trimming single spaces' 'this ' '<p>this</p>' | |||
| try -fnohtml 'markdown <br/> with -fnohtml' 'foo ' '<p>foo<br/> | |||
| </p>' | |||
| exit $rc | |||
| @ -0,0 +1,35 @@ | |||
| ./echo "pseudo-protocols" | |||
| 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 | |||
| } | |||
| try '[](id:) links' '[foo](id:bar)' '<p><a id="bar">foo</a></p>' | |||
| try -fnoext '[](id:) links with -fnoext' '[foo](id:bar)' '<p>[foo](id:bar)</p>' | |||
| try '[](class:) links' '[foo](class:bar)' '<p><span class="bar">foo</span></p>' | |||
| try -fnoext '[](class:) links with -fnoext' '[foo](class:bar)' '<p>[foo](class:bar)</p>' | |||
| try '[](raw:) links' '[foo](raw:bar)' '<p>bar</p>' | |||
| try -fnoext '[](raw:) links with -fnoext' '[foo](raw:bar)' '<p>[foo](raw:bar)</p>' | |||
| exit $rc | |||
| @ -0,0 +1,34 @@ | |||
| ./echo "footnotes inside reparse sections" | |||
| rc=0 | |||
| 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 | |||
| } | |||
| try 'footnote inside [] section' \ | |||
| '[![foo][]](bar) | |||
| [foo]: bar2' \ | |||
| '<p><a href="bar"><img src="bar2" alt="foo" /></a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,97 @@ | |||
| ./echo "Bugs & misfeatures reported by Mike Schiraldi" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| try() { | |||
| unset FLAGS | |||
| case "$1" in | |||
| -*) FLAGS=$1 | |||
| shift ;; | |||
| esac | |||
| S=`./echo -n "$1" '..................................' | ./cols 34` | |||
| ./echo -n " $S " | |||
| Q=`./echo "$2" | ./markdown $FLAGS` | |||
| if [ "$3" = "$Q" ]; then | |||
| ./echo "ok" | |||
| else | |||
| ./echo "FAILED" | |||
| ./echo "wanted: $3" | |||
| ./echo "got : $Q" | |||
| rc=1 | |||
| fi | |||
| } | |||
| try -fnohtml 'breaks with -fnohtml' 'foo ' '<p>foo<br/> | |||
| </p>' | |||
| try 'links with trailing \)' \ | |||
| '[foo](http://en.wikipedia.org/wiki/Link_(film\))' \ | |||
| '<p><a href="http://en.wikipedia.org/wiki/Link_(film)">foo</a></p>' | |||
| try -fautolink '(url) with -fautolink' \ | |||
| '(http://tsfr.org)' \ | |||
| '<p>(<a href="http://tsfr.org">http://tsfr.org</a>)</p>' | |||
| try 'single #' \ | |||
| '#' \ | |||
| '<p>#</p>' | |||
| try -frelax '* processing with -frelax' \ | |||
| '2*4 = 8 * 1 = 2**3' \ | |||
| '<p>2*4 = 8 * 1 = 2**3</p>' | |||
| try -fnopants '[]() with a single quote mark' \ | |||
| '[Poe'"'"'s law](http://rationalwiki.com/wiki/Poe'"'"'s_Law)' \ | |||
| '<p><a href="http://rationalwiki.com/wiki/Poe'"'"'s_Law">Poe'"'"'s law</a></p>' | |||
| try -fautolink 'autolink url with escaped spaces' \ | |||
| 'http://\(here\ I\ am\)' \ | |||
| '<p><a href="http://(here%20I%20am)">http://(here I am)</a></p>' | |||
| try -fautolink 'autolink café_racer' \ | |||
| 'http://en.wikipedia.org/wiki/café_racer' \ | |||
| '<p><a href="http://en.wikipedia.org/wiki/caf%C3%A9_racer">http://en.wikipedia.org/wiki/caf%C3%A9_racer</a></p>' | |||
| try -fautolink 'autolink url with arguments' \ | |||
| 'http://foo.bar?a&b=c' \ | |||
| '<p><a href="http://foo.bar?a&b=c">http://foo.bar?a&b=c</a></p>' | |||
| try '\( escapes in []()' \ | |||
| '[foo](http://a.com/\(foo\))' \ | |||
| '<p><a href="http://a.com/(foo)">foo</a></p>' | |||
| try -fautolink 'autolink url with escaped ()' \ | |||
| 'http://a.com/\(foo\)' \ | |||
| '<p><a href="http://a.com/(foo)">http://a.com/(foo)</a></p>' | |||
| try -fautolink 'autolink url with escaped \' \ | |||
| 'http://a.com/\\\)' \ | |||
| '<p><a href="http://a.com/\)">http://a.com/\)</a></p>' | |||
| try -fautolink 'autolink url with -' \ | |||
| 'http://experts-exchange.com' \ | |||
| '<p><a href="http://experts-exchange.com">http://experts-exchange.com</a></p>' | |||
| try -fautolink 'autolink url with +' \ | |||
| 'http://www67.wolframalpha.com/input/?i=how+old+was+jfk+jr+when+jfk+died' \ | |||
| '<p><a href="http://www67.wolframalpha.com/input/?i=how+old+was+jfk+jr+when+jfk+died">http://www67.wolframalpha.com/input/?i=how+old+was+jfk+jr+when+jfk+died</a></p>' | |||
| try -fautolink 'autolink url with &' \ | |||
| 'http://foo.bar?a&b=c' \ | |||
| '<p><a href="http://foo.bar?a&b=c">http://foo.bar?a&b=c</a></p>' | |||
| try -fautolink 'autolink url with ,' \ | |||
| 'http://www.spiegel.de/international/europe/0,1518,626171,00.html' \ | |||
| '<p><a href="http://www.spiegel.de/international/europe/0,1518,626171,00.html">http://www.spiegel.de/international/europe/0,1518,626171,00.html</a></p>' | |||
| try -fautolink 'autolink url with : & ;' \ | |||
| 'http://www.biblegateway.com/passage/?search=Matthew%205:29-30;&version=31;' \ | |||
| '<p><a href="http://www.biblegateway.com/passage/?search=Matthew%205:29-30;&version=31;">http://www.biblegateway.com/passage/?search=Matthew%205:29-30;&version=31;</a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,50 @@ | |||
| ./echo "smarty pants" | |||
| rc=0 | |||
| MARKDOWN_FLAGS=0x0; export 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 | |||
| } | |||
| try '(c) -> ©' '(c)' '<p>©</p>' | |||
| try '(r) -> ®' '(r)' '<p>®</p>' | |||
| try '(tm) -> ™' '(tm)' '<p>™</p>' | |||
| try '... -> …' '...' '<p>…</p>' | |||
| try '"--" -> —' '--' '<p>—</p>' | |||
| try '"-" -> –' 'regular -' '<p>regular –</p>' | |||
| try 'A-B -> A-B' 'A-B' '<p>A-B</p>' | |||
| try '"fancy" -> “fancy”' '"fancy"' '<p>“fancy”</p>' | |||
| try "'fancy'" "'fancy'" '<p>‘fancy’</p>' | |||
| try "don<b>'t -> don<b>’t" "don<b>'t" '<p>don<b>’t</p>' | |||
| try "don't -> don’t" "don't" '<p>don’t</p>' | |||
| try "it's -> it’s" "it's" '<p>it’s</p>' | |||
| if ./markdown -V | grep SUPERSCRIPT >/dev/null; then | |||
| try -frelax 'A^B -> A<sup>B</sup> (-frelax)' 'A^B' '<p>A<sup>B</sup></p>' | |||
| try -fstrict 'A^B != A<sup>B</sup> (-fstrict)' 'A^B' '<p>A^B</p>' | |||
| try -frelax 'A^B in link title' '[link](here "A^B")' '<p><a href="here" title="A^B">link</a></p>' | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,34 @@ | |||
| ./echo "The snakepit of Markdown.pl compatability" | |||
| 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 | |||
| } | |||
| try '[](single quote) text (quote)' \ | |||
| "[foo](http://Poe's law) will make this fail ('no, it won't!') here."\ | |||
| '<p><a href="http://Poe" title="s law) will make this fail ('"'no, it won't!"'">foo</a> here.</p>' | |||
| try '[](unclosed <url)' '[foo](<http://no trailing gt)' \ | |||
| '<p><a href="http://no%20trailing%20gt">foo</a></p>' | |||
| exit $rc | |||
| @ -0,0 +1,164 @@ | |||
| ./echo "tables" | |||
| 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 | |||
| } | |||
| try 'single-column table' \ | |||
| '|hello | |||
| |----- | |||
| |sailor' \ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th>hello</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td></td> | |||
| <td>sailor</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try 'two-column table' \ | |||
| ' | |||
| a | b | |||
| -----|------ | |||
| hello|sailor' \ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th> a </th> | |||
| <th> b</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td>hello</td> | |||
| <td>sailor</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try 'three-column table' \ | |||
| 'a|b|c | |||
| -|-|- | |||
| hello||sailor'\ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th>a</th> | |||
| <th>b</th> | |||
| <th>c</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td>hello</td> | |||
| <td></td> | |||
| <td>sailor</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try 'two-column table with empty cells' \ | |||
| ' | |||
| a | b | |||
| -----|------ | |||
| hello| | |||
| |sailor' \ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th> a </th> | |||
| <th> b</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td>hello</td> | |||
| <td></td> | |||
| </tr> | |||
| <tr> | |||
| <td> </td> | |||
| <td>sailor</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try 'two-column table with alignment' \ | |||
| ' | |||
| a | b | |||
| ----:|:----- | |||
| hello|sailor' \ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th align="right"> a </th> | |||
| <th align="left"> b</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td align="right">hello</td> | |||
| <td align="left">sailor</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try 'table with extra data column' \ | |||
| ' | |||
| a | b | |||
| -----|------ | |||
| hello|sailor|boy' \ | |||
| '<table> | |||
| <thead> | |||
| <tr> | |||
| <th> a </th> | |||
| <th> b</th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td>hello</td> | |||
| <td>sailor|boy</td> | |||
| </tr> | |||
| </tbody> | |||
| </table>' | |||
| try -fnotables 'tables with -fnotables' \ | |||
| 'a|b | |||
| -|- | |||
| hello|sailor' \ | |||
| '<p>a|b | |||
| –|– | |||
| hello|sailor</p>' | |||
| exit $rc | |||
| @ -0,0 +1,66 @@ | |||
| rc=0 | |||
| unset MARKDOWN_FLAGS | |||
| unset MKD_TABSTOP | |||
| 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 | |||
| } | |||
| eval `./markdown -V | tr ' ' '\n' | grep TAB` | |||
| if [ "${TAB:-4}" -eq 8 ]; then | |||
| ./echo "dealing with tabstop derangement" | |||
| LIST=' | |||
| * A | |||
| * B | |||
| * C' | |||
| try 'markdown with TAB=8' \ | |||
| "$LIST" \ | |||
| '<ul> | |||
| <li>A | |||
| <ul> | |||
| <li>B | |||
| <ul> | |||
| <li>C</li> | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| </ul>' | |||
| try -F0x0200 'markdown with TAB=4' \ | |||
| "$LIST" \ | |||
| '<ul> | |||
| <li>A | |||
| <ul> | |||
| <li>B</li> | |||
| <li>C</li> | |||
| </ul> | |||
| </li> | |||
| </ul>' | |||
| fi | |||
| exit $rc | |||
| @ -0,0 +1,41 @@ | |||
| ./echo "table-of-contents support" | |||
| 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 | |||
| } | |||
| try '-T -ftoc' 'table of contents' \ | |||
| '#H1 | |||
| hi' \ | |||
| ' | |||
| <ul> | |||
| <li><a href="#H1">H1</a> </li> | |||
| </ul> | |||
| <h1 id="H1">H1</h1> | |||
| <p>hi</p>' | |||
| exit $rc | |||
| @ -0,0 +1,39 @@ | |||
| ./echo "xml output with MKD_CDATA" | |||
| rc=0 | |||
| MARKDOWN_FLAGS= | |||
| try() { | |||
| unset FLAGS | |||
| case "$1" in | |||
| -*) FLAGS=$1 | |||
| shift ;; | |||
| esac | |||
| ./echo -n " $1" '..................................' | ./cols 36 | |||
| case "$2" in | |||
| -t*) Q=`./markdown $FLAGS "$2"` ;; | |||
| *) Q=`./echo "$2" | ./markdown $FLAGS` ;; | |||
| esac | |||
| if [ "$3" = "$Q" ]; then | |||
| ./echo " ok" | |||
| else | |||
| ./echo " FAILED" | |||
| ./echo "wanted: $3" | |||
| ./echo "got : $Q" | |||
| rc=1 | |||
| fi | |||
| } | |||
| try -fcdata 'xml output from markdown()' 'hello,sailor' '<p>hello,sailor</p>' | |||
| try -fcdata 'from mkd_generateline()' -t'"hello,sailor"' '&ldquo;hello,sailor&rdquo;' | |||
| try -fnocdata 'html output from markdown()' '"hello,sailor"' '<p>“hello,sailor”</p>' | |||
| try -fnocdata '... from mkd_generateline()' -t'"hello,sailor"' '“hello,sailor”' | |||
| try -fcdata 'xml output with multibyte utf-8' \ | |||
| 'tecnología y servicios más confiables' \ | |||
| '<p>tecnología y servicios más confiables</p>' | |||
| exit $rc | |||
| @ -0,0 +1,38 @@ | |||
| #include <stdio.h> | |||
| #include <stdlib.h> | |||
| main(argc, argv) | |||
| char **argv; | |||
| { | |||
| register c; | |||
| int xp; | |||
| int width; | |||
| if ( argc != 2 ) { | |||
| fprintf(stderr, "usage: %s width\n", argv[0]); | |||
| exit(1); | |||
| } | |||
| else if ( (width=atoi(argv[1])) < 1 ) { | |||
| fprintf(stderr, "%s: please set width to > 0\n", argv[0]); | |||
| exit(1); | |||
| } | |||
| for ( xp = 1; (c = getchar()) != EOF; xp++ ) { | |||
| while ( c & 0xC0 ) { | |||
| /* assume that (1) the output device understands utf-8, and | |||
| * (2) the only c & 0x80 input is utf-8. | |||
| */ | |||
| do { | |||
| if ( xp <= width ) | |||
| putchar(c); | |||
| } while ( (c = getchar()) != EOF && (c & 0x80) && !(c & 0x40) ); | |||
| ++xp; | |||
| } | |||
| if ( c == '\n' ) | |||
| xp = 0; | |||
| if ( xp <= width ) | |||
| putchar(c); | |||
| } | |||
| exit(0); | |||
| } | |||