Compare commits

...

1 Commits

Author SHA1 Message Date
  sekimura 16f3fba530 discount-1.5.5 14 years ago
103 changed files with 4319 additions and 2011 deletions
Split View
  1. +79
    -61
      MANIFEST
  2. +3
    -1
      Makefile.PL
  3. +0
    -90
      discount-1.3.4/Makefile.in
  4. +0
    -1
      discount-1.3.4/VERSION
  5. +0
    -49
      discount-1.3.4/tests/code.t
  6. +0
    -67
      discount-1.3.4/tests/compat.t
  7. +0
    -82
      discount-1.3.4/tests/dl.t
  8. +0
    -81
      discount-1.3.4/tests/emphasis.t
  9. +0
    -43
      discount-1.3.4/tests/flow.t
  10. +0
    -33
      discount-1.3.4/tests/footnotes.t
  11. +0
    -118
      discount-1.3.4/tests/html.t
  12. +0
    -149
      discount-1.3.4/tests/linkylinky.t
  13. +0
    -15
      discount-1.3.4/tests/linkypix.t
  14. +0
    -147
      discount-1.3.4/tests/list.t
  15. +0
    -25
      discount-1.3.4/tests/list3deep.t
  16. +0
    -46
      discount-1.3.4/tests/misc.t
  17. +0
    -96
      discount-1.3.4/tests/pandoc.t
  18. +0
    -32
      discount-1.3.4/tests/para.t
  19. +0
    -85
      discount-1.3.4/tests/peculiarities.t
  20. +0
    -76
      discount-1.3.4/tests/pseudo.t
  21. +0
    -18
      discount-1.3.4/tests/reparse.t
  22. +0
    -140
      discount-1.3.4/tests/smarty.t
  23. +0
    -29
      discount-1.3.4/tests/tabstop.t
  24. +0
    -44
      discount-1.3.4/tests/xml.t
  25. +0
    -0
      discount-1.5.5/COPYRIGHT
  26. +33
    -0
      discount-1.5.5/CREDITS
  27. +14
    -2
      discount-1.5.5/Csio.c
  28. +0
    -0
      discount-1.5.5/INSTALL
  29. +96
    -0
      discount-1.5.5/Makefile.in
  30. +40
    -0
      discount-1.5.5/Plan9/README
  31. +169
    -0
      discount-1.5.5/Plan9/markdown.1
  32. +332
    -0
      discount-1.5.5/Plan9/markdown.2
  33. +543
    -0
      discount-1.5.5/Plan9/markdown.6
  34. +37
    -0
      discount-1.5.5/Plan9/mkfile
  35. +0
    -0
      discount-1.5.5/README
  36. +1
    -0
      discount-1.5.5/VERSION
  37. +0
    -0
      discount-1.5.5/amalloc.c
  38. +0
    -0
      discount-1.5.5/amalloc.h
  39. +0
    -0
      discount-1.5.5/configure.inc
  40. +2
    -2
      discount-1.5.5/configure.sh
  41. +76
    -0
      discount-1.5.5/css.c
  42. +7
    -5
      discount-1.5.5/cstring.h
  43. +0
    -0
      discount-1.5.5/docheader.c
  44. +5
    -1
      discount-1.5.5/dumptree.c
  45. +473
    -268
      discount-1.5.5/generate.c
  46. +15
    -9
      discount-1.5.5/main.c
  47. +0
    -0
      discount-1.5.5/makepage.c
  48. +10
    -2
      discount-1.5.5/markdown.1.in
  49. +21
    -27
      discount-1.5.5/markdown.3
  50. +0
    -0
      discount-1.5.5/markdown.7
  51. +202
    -72
      discount-1.5.5/markdown.c
  52. +16
    -5
      discount-1.5.5/markdown.h
  53. +44
    -0
      discount-1.5.5/mkd-extensions.7
  54. +12
    -5
      discount-1.5.5/mkd-functions.3
  55. +41
    -0
      discount-1.5.5/mkd-line.3
  56. +1
    -1
      discount-1.5.5/mkd2html.c
  57. +68
    -6
      discount-1.5.5/mkdio.c
  58. +20
    -7
      discount-1.5.5/mkdio.h
  59. +13
    -27
      discount-1.5.5/resource.c
  60. +42
    -0
      discount-1.5.5/tests/autolink.t
  61. +53
    -0
      discount-1.5.5/tests/automatic.t
  62. +35
    -0
      discount-1.5.5/tests/backslash.t
  63. +0
    -0
      discount-1.5.5/tests/chrome.text
  64. +39
    -0
      discount-1.5.5/tests/code.t
  65. +47
    -0
      discount-1.5.5/tests/compat.t
  66. +9
    -0
      discount-1.5.5/tests/crash.t
  67. +67
    -0
      discount-1.5.5/tests/div.t
  68. +69
    -0
      discount-1.5.5/tests/dl.t
  69. +0
    -0
      discount-1.5.5/tests/embedlinks.text
  70. +40
    -0
      discount-1.5.5/tests/emphasis.t
  71. +52
    -0
      discount-1.5.5/tests/flow.t
  72. +34
    -0
      discount-1.5.5/tests/footnotes.t
  73. +12
    -3
      discount-1.5.5/tests/header.t
  74. +109
    -0
      discount-1.5.5/tests/html.t
  75. +0
    -0
      discount-1.5.5/tests/links.text
  76. +124
    -0
      discount-1.5.5/tests/linkylinky.t
  77. +31
    -0
      discount-1.5.5/tests/linkypix.t
  78. +168
    -0
      discount-1.5.5/tests/list.t
  79. +57
    -0
      discount-1.5.5/tests/list3deep.t
  80. +33
    -0
      discount-1.5.5/tests/misc.t
  81. +74
    -0
      discount-1.5.5/tests/pandoc.t
  82. +38
    -0
      discount-1.5.5/tests/para.t
  83. +31
    -0
      discount-1.5.5/tests/paranoia.t
  84. +64
    -0
      discount-1.5.5/tests/peculiarities.t
  85. +35
    -0
      discount-1.5.5/tests/pseudo.t
  86. +34
    -0
      discount-1.5.5/tests/reparse.t
  87. +97
    -0
      discount-1.5.5/tests/schiraldi.t
  88. +50
    -0
      discount-1.5.5/tests/smarty.t
  89. +34
    -0
      discount-1.5.5/tests/snakepit.t
  90. +0
    -0
      discount-1.5.5/tests/style.t
  91. +0
    -0
      discount-1.5.5/tests/syntax.text
  92. +164
    -0
      discount-1.5.5/tests/tables.t
  93. +66
    -0
      discount-1.5.5/tests/tabstop.t
  94. +41
    -0
      discount-1.5.5/tests/toc.t
  95. +39
    -0
      discount-1.5.5/tests/xml.t
  96. +0
    -0
      discount-1.5.5/theme.1
  97. +12
    -18
      discount-1.5.5/theme.c
  98. +24
    -20
      discount-1.5.5/toc.c
  99. +38
    -0
      discount-1.5.5/tools/cols.c
  100. +0
    -0
      discount-1.5.5/tools/echo.c

+ 79
- 61
MANIFEST View File

@ -1,66 +1,84 @@
.gitignore
Changes
discount-1.3.4/amalloc.c
discount-1.3.4/amalloc.h
discount-1.3.4/configure.inc
discount-1.3.4/configure.sh
discount-1.3.4/COPYRIGHT
discount-1.3.4/Csio.c
discount-1.3.4/cstring.h
discount-1.3.4/docheader.c
discount-1.3.4/dumptree.c
discount-1.3.4/echo.c
discount-1.3.4/generate.c
discount-1.3.4/INSTALL
discount-1.3.4/main.c
discount-1.3.4/Makefile
discount-1.3.4/Makefile.in
discount-1.3.4/makepage.c
discount-1.3.4/markdown.1.in
discount-1.3.4/markdown.3
discount-1.3.4/markdown.7
discount-1.3.4/markdown.c
discount-1.3.4/markdown.h
discount-1.3.4/mkd-extensions.7
discount-1.3.4/mkd-functions.3
discount-1.3.4/mkd2html.c
discount-1.3.4/mkdio.c
discount-1.3.4/mkdio.h
discount-1.3.4/README
discount-1.3.4/resource.c
discount-1.3.4/tests/chrome.text
discount-1.3.4/tests/code.t
discount-1.3.4/tests/compat.t
discount-1.3.4/tests/crash.t
discount-1.3.4/tests/dl.t
discount-1.3.4/tests/embedlinks.text
discount-1.3.4/tests/emphasis.t
discount-1.3.4/tests/flow.t
discount-1.3.4/tests/footnotes.t
discount-1.3.4/tests/header.t
discount-1.3.4/tests/html.t
discount-1.3.4/tests/links.text
discount-1.3.4/tests/linkylinky.t
discount-1.3.4/tests/linkypix.t
discount-1.3.4/tests/list.t
discount-1.3.4/tests/list3deep.t
discount-1.3.4/tests/misc.t
discount-1.3.4/tests/pandoc.t
discount-1.3.4/tests/para.t
discount-1.3.4/tests/peculiarities.t
discount-1.3.4/tests/pseudo.t
discount-1.3.4/tests/reparse.t
discount-1.3.4/tests/smarty.t
discount-1.3.4/tests/style.t
discount-1.3.4/tests/syntax.text
discount-1.3.4/tests/tabstop.t
discount-1.3.4/tests/xml.t
discount-1.3.4/theme.1
discount-1.3.4/theme.c
discount-1.3.4/toc.c
discount-1.3.4/VERSION
discount-1.3.4/version.c.in
discount-1.3.4/xmlpage.c
discount-1.5.5/COPYRIGHT
discount-1.5.5/CREDITS
discount-1.5.5/Csio.c
discount-1.5.5/INSTALL
discount-1.5.5/Makefile.in
discount-1.5.5/Plan9/README
discount-1.5.5/Plan9/markdown.1
discount-1.5.5/Plan9/markdown.2
discount-1.5.5/Plan9/markdown.6
discount-1.5.5/Plan9/mkfile
discount-1.5.5/README
discount-1.5.5/VERSION
discount-1.5.5/amalloc.c
discount-1.5.5/amalloc.h
discount-1.5.5/configure.inc
discount-1.5.5/configure.sh
discount-1.5.5/css.c
discount-1.5.5/cstring.h
discount-1.5.5/docheader.c
discount-1.5.5/dumptree.c
discount-1.5.5/generate.c
discount-1.5.5/main.c
discount-1.5.5/makepage.c
discount-1.5.5/markdown.1.in
discount-1.5.5/markdown.3
discount-1.5.5/markdown.7
discount-1.5.5/markdown.c
discount-1.5.5/markdown.h
discount-1.5.5/mkd-extensions.7
discount-1.5.5/mkd-functions.3
discount-1.5.5/mkd-line.3
discount-1.5.5/mkd2html.c
discount-1.5.5/mkdio.c
discount-1.5.5/mkdio.h
discount-1.5.5/resource.c
discount-1.5.5/tests/autolink.t
discount-1.5.5/tests/automatic.t
discount-1.5.5/tests/backslash.t
discount-1.5.5/tests/chrome.text
discount-1.5.5/tests/code.t
discount-1.5.5/tests/compat.t
discount-1.5.5/tests/crash.t
discount-1.5.5/tests/div.t
discount-1.5.5/tests/dl.t
discount-1.5.5/tests/embedlinks.text
discount-1.5.5/tests/emphasis.t
discount-1.5.5/tests/flow.t
discount-1.5.5/tests/footnotes.t
discount-1.5.5/tests/header.t
discount-1.5.5/tests/html.t
discount-1.5.5/tests/links.text
discount-1.5.5/tests/linkylinky.t
discount-1.5.5/tests/linkypix.t
discount-1.5.5/tests/list.t
discount-1.5.5/tests/list3deep.t
discount-1.5.5/tests/misc.t
discount-1.5.5/tests/pandoc.t
discount-1.5.5/tests/para.t
discount-1.5.5/tests/paranoia.t
discount-1.5.5/tests/peculiarities.t
discount-1.5.5/tests/pseudo.t
discount-1.5.5/tests/reparse.t
discount-1.5.5/tests/schiraldi.t
discount-1.5.5/tests/smarty.t
discount-1.5.5/tests/snakepit.t
discount-1.5.5/tests/style.t
discount-1.5.5/tests/syntax.text
discount-1.5.5/tests/tables.t
discount-1.5.5/tests/tabstop.t
discount-1.5.5/tests/toc.t
discount-1.5.5/tests/xml.t
discount-1.5.5/theme.1
discount-1.5.5/theme.c
discount-1.5.5/toc.c
discount-1.5.5/tools/cols.c
discount-1.5.5/tools/echo.c
discount-1.5.5/version.c.in
discount-1.5.5/xml.c
discount-1.5.5/xmlpage.c
Discount.xs
INSTALL.Discount
lib/Text/Markdown/Discount.pm


+ 3
- 1
Makefile.PL View File

@ -4,7 +4,7 @@ use warnings;
use ExtUtils::MakeMaker;
use File::Spec;
my $extdir = 'discount-1.3.4';
my $extdir = 'discount-1.5.5';
my $myextlib = File::Spec->catfile($extdir, 'libmarkdown.a');
my $clean_files = join (" ",
map{ File::Spec->catfile($extdir, $_) }
@ -32,6 +32,8 @@ my $clean_files = join (" ",
version.c
version.o
xmlpage.o
css.o
xml.o
));


+ 0
- 90
discount-1.3.4/Makefile.in View File

@ -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

+ 0
- 1
discount-1.3.4/VERSION View File

@ -1 +0,0 @@
1.3.4

+ 0
- 49
discount-1.3.4/tests/code.t View File

@ -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

+ 0
- 67
discount-1.3.4/tests/compat.t View File

@ -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

+ 0
- 82
discount-1.3.4/tests/dl.t View File

@ -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

+ 0
- 81
discount-1.3.4/tests/emphasis.t View File

@ -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

+ 0
- 43
discount-1.3.4/tests/flow.t View File

@ -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

+ 0
- 33
discount-1.3.4/tests/footnotes.t View File

@ -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

+ 0
- 118
discount-1.3.4/tests/html.t View File

@ -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

+ 0
- 149
discount-1.3.4/tests/linkylinky.t View File

@ -1,149 +0,0 @@
./echo "embedded links"
rc=0
MARKDOWN_FLAGS=
./echo -n ' url contains & ................... '
if ./echo '[hehehe](u&rl)' | ./markdown | grep -i '&amp;' >/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 '&lt;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' label contains < ................. '
if ./echo '![he<he<he](url)' | ./markdown | grep -i '&lt;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' label contains < ................. '
if ./echo '![he<he<he](url)' | ./markdown | grep -i '&lt;' >/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 '&#00;' >/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

+ 0
- 15
discount-1.3.4/tests/linkypix.t View File

@ -1,15 +0,0 @@
./echo "embedded images"
rc=0
MARKDOWN_FLAGS=
./echo -n ' image with size extension ........ '
if ./echo '![picture](pic =200x200)' | ./markdown | grep -i 'width=' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
exit $rc

+ 0
- 147
discount-1.3.4/tests/list.t View File

@ -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

+ 0
- 25
discount-1.3.4/tests/list3deep.t View File

@ -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

+ 0
- 46
discount-1.3.4/tests/misc.t View File

@ -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 ' < -> &lt; ........................ '
if ./echo '<' | ./markdown | grep -i '&lt;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' `>` -> <code>&gt;</code> ......... '
if ./echo '`>`' | ./markdown | grep -i '<code>&gt;</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

+ 0
- 96
discount-1.3.4/tests/pandoc.t View File

@ -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

+ 0
- 32
discount-1.3.4/tests/para.t View File

@ -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

+ 0
- 85
discount-1.3.4/tests/peculiarities.t View File

@ -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

+ 0
- 76
discount-1.3.4/tests/pseudo.t View File

@ -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

+ 0
- 18
discount-1.3.4/tests/reparse.t View File

@ -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

+ 0
- 140
discount-1.3.4/tests/smarty.t View File

@ -1,140 +0,0 @@
./echo "smarty pants"
rc=0
MARKDOWN_FLAGS=
MARKDOWN_FLAGS=0x0; export MARKDOWN_FLAGS
./echo -n ' (c) -> &copy; .................... '
if ./echo '(c)' | ./markdown | grep '&copy;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' (r) -> &reg; ..................... '
if ./echo '(r)' | ./markdown | grep '&reg;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' (tm) -> &trade; .................. '
if ./echo '(tm)' | ./markdown | grep '&trade;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' ... -> &hellip; .................. '
if ./echo '...' | ./markdown | grep '&hellip;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' -- -> &mdash; .................... '
if ./echo '--' | ./markdown | grep '&mdash;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' - -> &ndash; ..................... '
if ./echo 'regular - ' | ./markdown | grep '&ndash;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' A-B -> A-B ....................... '
if ./echo 'A-B' | ./markdown | grep '&ndash;' >/dev/null; then
./echo "FAILED"
rc=1
else
./echo "ok"
fi
./echo -n ' "fancy" -> &ldquo;fancy&rdquo; ... '
if ./echo '"fancy"' | ./markdown | grep '&ldquo;fancy&rdquo;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' '"'fancy'"' -> &lsquo;fancy&rsquo; ... '
if ./echo "'fancy'" | ./markdown | grep '&lsquo;fancy&rsquo;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n " don<b>'t -> don<b>&rsquo;t ....... "
if ./echo "don<b>'t" | ./markdown | grep 'don<b>&rsquo;t' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n " don't -> don&rsquo;t ............. "
if ./echo "don't" | ./markdown | grep 'don&rsquo;t' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n " it's -> it&rsquo;s ............... "
if ./echo "it's" | ./markdown | grep 'it&rsquo;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

+ 0
- 29
discount-1.3.4/tests/tabstop.t View File

@ -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

+ 0
- 44
discount-1.3.4/tests/xml.t View File

@ -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 '&amp;' >/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
./echo -n ' html output from markdown() ...... '
if ./echo '"hello,sailor"' | ./markdown -fnocdata | grep '&amp;' >/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 '&amp;' >/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 '&amp;' >/dev/null; then
./echo "FAILED"
rc=1
else
./echo "ok"
fi
exit $rc

discount-1.3.4/COPYRIGHT → discount-1.5.5/COPYRIGHT View File


+ 33
- 0
discount-1.5.5/CREDITS View File

@ -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.

discount-1.3.4/Csio.c → discount-1.5.5/Csio.c View File

@ -26,15 +26,27 @@ Csprintf(Cstring *iot, char *fmt, ...)
do {
RESERVE(*iot, siz);
va_start(ptr, fmt);
siz = vsnprintf(T(*iot)+S(*iot), ALL(*iot)-S(*iot), fmt, ptr);
siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
va_end(ptr);
} while ( siz > (ALL(*iot)-S(*iot)) );
} while ( siz > (ALLOCATED(*iot)-S(*iot)) );
S(*iot) += siz;
return siz;
}
/* write() into a cstring
*/
int
Cswrite(Cstring *iot, char *bfr, int size)
{
RESERVE(*iot, size);
memcpy(T(*iot)+S(*iot), bfr, size);
S(*iot) += size;
return size;
}
/* reparse() into a cstring
*/
void

discount-1.3.4/INSTALL → discount-1.5.5/INSTALL View File


+ 96
- 0
discount-1.5.5/Makefile.in View File

@ -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

+ 40
- 0
discount-1.5.5/Plan9/README View File

@ -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.

+ 169
- 0
discount-1.5.5/Plan9/markdown.1 View File

@ -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.

+ 332
- 0
discount-1.5.5/Plan9/markdown.2 View File

@ -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.

+ 543
- 0
discount-1.5.5/Plan9/markdown.6 View File

@ -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
![Alt text](/path/to/img.jpg "Optional title")
.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 &lt;
and
.BR &amp; .
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 &amp; .
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 &lsquo;text&rsquo; ).
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 ( &hellip; )
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 &copy; ,
the Copyright symbol entity.)
.TP
Fractions
A small set of plain-text shorthands for fractions is recognized.
.B 1/4
becomes
.BR &frac14; ,
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
![Alt text](/path/to/image.jpg =400x300 "Title")
.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''.

+ 37
- 0
discount-1.5.5/Plan9/mkfile View File

@ -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'

discount-1.3.4/README → discount-1.5.5/README View File


+ 1
- 0
discount-1.5.5/VERSION View File

@ -0,0 +1 @@
1.5.5

discount-1.3.4/amalloc.c → discount-1.5.5/amalloc.c View File


discount-1.3.4/amalloc.h → discount-1.5.5/amalloc.h View File


discount-1.3.4/configure.inc → discount-1.5.5/configure.inc View File


discount-1.3.4/configure.sh → discount-1.5.5/configure.sh View File

@ -15,7 +15,7 @@ ac_help='--enable-dl-tag Use the DL tag extension
--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 optional features'
--enable-all-features Turn on all stable optional features'
LOCAL_AC_OPTIONS='
set=`locals $*`;
@ -40,7 +40,7 @@ locals() {
echo WITH_AMALLOC=T
echo WITH_DIV=T
#echo WITH_ALPHA_LIST=T
echo WITH_TABSTOPS=8 ;;
;;
--ENABLE-*) enable=`echo $K | sed -e 's/--ENABLE-//' | tr '-' '_'`
echo WITH_${enable}=T ;;
esac

+ 76
- 0
discount-1.5.5/css.c View File

@ -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;
}

discount-1.3.4/cstring.h → discount-1.5.5/cstring.h View File

@ -22,8 +22,8 @@
: (T(x) = T(x) ? realloc(T(x), sizeof T(x)[0] * ((x).alloc += 100)) \
: malloc(sizeof T(x)[0] * ((x).alloc += 100)) )]
#define DELETE(x) (x).alloc ? (free(T(x)), S(x) = (x).alloc = 0) \
: ( S(x) = 0 )
#define DELETE(x) ALLOCATED(x) ? (free(T(x)), S(x) = (x).alloc = 0) \
: ( S(x) = 0 )
#define CLIP(t,i,sz) \
( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \
(memmove(&T(t)[i], &T(t)[i+sz], (S(t)-(i+sz)+1)*sizeof(T(t)[0])), \
@ -50,7 +50,7 @@
*/
#define T(x) (x).text
#define S(x) (x).size
#define ALL(x) (x).alloc
#define ALLOCATED(x) (x).alloc
/* abstract anchor type that defines a list base
* with a function that attaches an element to
@ -60,14 +60,16 @@
* macro will work with it.
*/
#define ANCHOR(t) struct { t *text, *end; }
#define E(t) ((t).end)
#define ATTACH(t, p) ( (t).text ?( ((t).end->next = (p)), ((t).end = (p)) ) \
:( ((t).text = (t).end = (p)) ) )
#define ATTACH(t, p) ( T(t) ? ( (E(t)->next = (p)), (E(t) = (p)) ) \
: ( (T(t) = E(t) = (p)) ) )
typedef STRING(char) Cstring;
extern void Csputc(int, Cstring *);
extern int Csprintf(Cstring *, char *, ...);
extern int Cswrite(Cstring *, char *, int);
extern void Csreparse(Cstring *, char *, int, int);
#endif/*_CSTRING_D*/

discount-1.3.4/docheader.c → discount-1.5.5/docheader.c View File


discount-1.3.4/dumptree.c → discount-1.5.5/dumptree.c View File

@ -30,7 +30,9 @@ Pptype(int typ)
case OL : return "ol";
case LISTITEM : return "item";
case HDR : return "header";
case HR : return "HR";
case HR : return "hr";
case TABLE : return "table";
case SOURCE : return "source";
default : return "mystery node!";
}
}
@ -106,6 +108,8 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
printpfx(sp, f);
d = fprintf(f, "[%s", Pptype(pp->typ));
if ( pp->ident )
d += fprintf(f, " %s", pp->ident);
if ( pp->align )
d += fprintf(f, ", <%s>", Begin[pp->align]);

discount-1.3.4/generate.c → discount-1.5.5/generate.c View File

@ -17,11 +17,6 @@
#include "markdown.h"
#include "amalloc.h"
/* prefixes for <automatic links>
*/
static char *autoprefix[] = { "http://", "https://", "ftp://", "news://" };
#define SZAUTOPREFIX (sizeof autoprefix / sizeof autoprefix[0])
typedef int (*stfu)(const void*,const void*);
@ -119,7 +114,7 @@ shift(MMIOT *f, int i)
/* Qchar()
*/
static void
Qchar(char c, MMIOT *f)
Qchar(int c, MMIOT *f)
{
block *cur;
@ -328,18 +323,27 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f)
* write out a url, escaping problematic characters
*/
static void
puturl(char *s, int size, MMIOT *f)
puturl(char *s, int size, MMIOT *f, int display)
{
unsigned char c;
while ( size-- > 0 ) {
c = *s++;
if ( c == '\\' && size-- > 0 ) {
c = *s++;
if ( !( ispunct(c) || isspace(c) ) )
Qchar('\\', f);
}
if ( c == '&' )
Qstring("&amp;", f);
else if ( c == '<' )
Qstring("&lt;", f);
else if ( isalnum(c) || ispunct(c) )
else if ( c == '"' )
Qstring("%22", f);
else if ( isalnum(c) || ispunct(c) || (display && isspace(c)) )
Qchar(c, f);
else
Qprintf(f, "%%%02X", c);
@ -372,181 +376,164 @@ parenthetical(int in, int out, MMIOT *f)
return EOF;
else if ( c == in )
++indent;
else if ( (c == '\\') && (peek(f,1) == out) ) {
++size;
pull(f);
}
else if ( c == out )
--indent;
}
return size-1;
return size ? (size-1) : 0;
}
/* extract a []-delimited label from the input stream.
*/
static char *
linkylabel(MMIOT *f, int *sizep)
static int
linkylabel(MMIOT *f, Cstring *res)
{
char *ptr = cursor(f);
int size;
if ( (*sizep = parenthetical('[',']',f)) != EOF )
return ptr;
if ( (size = parenthetical('[',']',f)) != EOF ) {
T(*res) = ptr;
S(*res) = size;
return 1;
}
return 0;
}
/* extract a (-prefixed url from the input stream.
* the label is either of the format `<link>`, where I
* extract until I find a >, or it is of the format
* `text`, where I extract until I reach a ')' or
* whitespace.
/* see if the quote-prefixed linky segment is actually a title.
*/
static char*
linkyurl(MMIOT *f, int *sizep)
static int
linkytitle(MMIOT *f, char quote, Footnote *ref)
{
int size = 0;
char *ptr;
int c;
int whence = mmiottell(f);
char *title = cursor(f);
char *e;
register int c;
if ( (c = eatspace(f)) == EOF )
return 0;
ptr = cursor(f);
if ( c == '<' ) {
pull(f);
ptr++;
if ( (size = parenthetical('<', '>', f)) == EOF )
return 0;
}
else {
for ( ; ((c=pull(f)) != ')') && !isspace(c); size++)
if ( c == EOF ) return 0;
if ( c == ')' )
shift(f, -1);
while ( (c = pull(f)) != EOF ) {
e = cursor(f);
if ( c == quote ) {
if ( (c = eatspace(f)) == ')' ) {
T(ref->title) = 1+title;
S(ref->title) = (e-title)-2;
return 1;
}
}
}
*sizep = size;
return ptr;
mmiotseek(f, whence);
return 0;
}
/* extract a =HHHxWWW size from the input stream
*/
static int
linkysize(MMIOT *f, int *heightp, int *widthp)
linkysize(MMIOT *f, Footnote *ref)
{
int height=0, width=0;
int whence = mmiottell(f);
int c;
*heightp = 0;
*widthp = 0;
if ( isspace(peek(f,0)) ) {
pull(f); /* eat '=' */
if ( (c = eatspace(f)) != '=' )
return (c != EOF);
pull(f); /* eat '=' */
for ( c = pull(f); isdigit(c); c = pull(f))
width = (width * 10) + (c - '0');
if ( c == 'x' ) {
for ( c = pull(f); isdigit(c); c = pull(f))
height = (height*10) + (c - '0');
if ( c != EOF ) {
if ( !isspace(c) ) shift(f, -1);
*heightp = height;
*widthp = width;
return 1;
}
}
return 0;
}
width = (width * 10) + (c - '0');
if ( c == 'x' ) {
for ( c = pull(f); isdigit(c); c = pull(f))
height = (height*10) + (c - '0');
/* extract a )-terminated title from the input stream.
*/
static char*
linkytitle(MMIOT *f, int *sizep)
{
int countq=0, qc, c, size;
char *ret, *lastqc = 0;
eatspace(f);
if ( (qc=pull(f)) != '"' && qc != '\'' && qc != '(' )
return 0;
if ( isspace(c) )
c = eatspace(f);
if ( qc == '(' ) qc = ')';
for ( ret = cursor(f); (c = pull(f)) != EOF; ) {
if ( (c == ')') && countq ) {
size = (lastqc ? lastqc : cursor(f)) - ret;
*sizep = size-1;
return ret;
}
else if ( c == qc ) {
lastqc = cursor(f);
countq++;
if ( (c == ')') || ((c == '\'' || c == '"') && linkytitle(f, c, ref)) ) {
ref->height = height;
ref->width = width;
return 1;
}
}
}
mmiotseek(f, whence);
return 0;
}
/* look up (or construct) a footnote from the [xxx] link
* at the head of the stream.
/* extract a (-prefixed url from the input stream.
* the label is either of the format `<link>`, where I
* extract until I find a >, or it is of the format
* `text`, where I extract until I reach a ')', a quote,
* or (if image) a '='
*/
static int
linkykey(int image, Footnote *val, MMIOT *f)
linkyurl(MMIOT *f, int image, Footnote *p)
{
Footnote *ret;
Cstring mylabel;
int here;
memset(val, 0, sizeof *val);
int c;
int mayneedtotrim=0;
if ( (T(val->tag) = linkylabel(f, &S(val->tag))) == 0 )
if ( (c = eatspace(f)) == EOF )
return 0;
here = mmiottell(f);
eatspace(f);
switch ( pull(f) ) {
case '(':
/* embedded link */
if ( (T(val->link) = linkyurl(f,&S(val->link))) == 0 )
return 0;
if ( c == '<' ) {
pull(f);
mayneedtotrim=1;
}
if ( image && !linkysize(f, &val->height, &val->width) )
T(p->link) = cursor(f);
for ( S(p->link)=0; (c = peek(f,1)) != ')'; ++S(p->link) ) {
if ( c == EOF )
return 0;
else if ( (c == '"' || c == '\'') && linkytitle(f, c, p) )
break;
else if ( image && (c == '=') && linkysize(f, p) )
break;
else if ( (c == '\\') && ispunct(peek(f,2)) ) {
++S(p->link);
pull(f);
}
pull(f);
}
if ( peek(f, 1) == ')' )
pull(f);
___mkd_tidy(&p->link);
if ( mayneedtotrim && (T(p->link)[S(p->link)-1] == '>') )
--S(p->link);
return 1;
}
T(val->title) = linkytitle(f, &S(val->title));
return peek(f,0) == ')';
case '[': /* footnote links /as defined in the standard/ */
default: /* footnote links -- undocumented extension */
/* footnote link */
mylabel = val->tag;
if ( peek(f,0) == '[' ) {
if ( (T(val->tag) = linkylabel(f, &S(val->tag))) == 0 )
return 0;
/* prefixes for <automatic links>
*/
static struct {
char *name;
int nlen;
} protocol[] = {
#define _aprotocol(x) { x, (sizeof x)-1 }
_aprotocol( "http://" ),
_aprotocol( "https://" ),
_aprotocol( "ftp://" ),
_aprotocol( "news://" ),
#undef _aprotocol
};
#define NRPROTOCOLS (sizeof protocol / sizeof protocol[0])
if ( !S(val->tag) )
val->tag = mylabel;
}
else if ( f->flags & MKD_1_COMPAT )
break;
else
mmiotseek(f,here);
ret = bsearch(val, T(*f->footnotes), S(*f->footnotes),
sizeof *val, (stfu)__mkd_footsort);
static int
isautoprefix(char *text)
{
int i;
if ( ret ) {
val->tag = mylabel;
val->link = ret->link;
val->title = ret->title;
val->height = ret->height;
val->width = ret->width;
for (i=0; i < NRPROTOCOLS; i++)
if ( strncasecmp(text, protocol[i].name, protocol[i].nlen) == 0 )
return 1;
}
}
return 0;
}
@ -564,12 +551,14 @@ typedef struct linkytype {
char *text_pfx; /* text prefix (eg: ">" */
char *text_sfx; /* text suffix (eg: "</a>" */
int flags; /* reparse flags */
int kind; /* tag is url or something else? */
#define IS_URL 0x01
} linkytype;
static linkytype imaget = { 0, 0, "<img src=\"", "\"",
1, " alt=\"", "\" />", DENY_IMG|INSIDE_TAG };
1, " alt=\"", "\" />", DENY_IMG|INSIDE_TAG, IS_URL };
static linkytype linkt = { 0, 0, "<a href=\"", "\"",
0, ">", "</a>", DENY_A };
0, ">", "</a>", DENY_A, IS_URL };
/*
* pseudo-protocols for [][];
@ -579,9 +568,10 @@ static linkytype linkt = { 0, 0, "<a href=\"", "\"",
* raw: just dump the link without any processing
*/
static linkytype specials[] = {
{ "id:", 3, "<a id=\"", "\"", 0, ">", "</a>", 0 },
{ "class:", 6, "<span class=\"", "\"", 0, ">", "</span>", 0 },
{ "raw:", 4, 0, 0, 0, 0, 0, 0 },
{ "id:", 3, "<a id=\"", "\"", 0, ">", "</a>", 0, IS_URL },
{ "class:", 6, "<span class=\"", "\"", 0, ">", "</span>", 0, 0 },
{ "raw:", 4, 0, 0, 0, 0, 0, DENY_HTML, 0 },
{ "abbr:", 5, "<abbr title=\"", "\"", 0, ">", "</abbr>", 0, 0 },
} ;
#define NR(x) (sizeof x / sizeof x[0])
@ -589,7 +579,7 @@ static linkytype specials[] = {
/* see if t contains one of our pseudo-protocols.
*/
static linkytype *
extratag(Cstring t)
pseudo(Cstring t)
{
int i;
linkytype *r;
@ -603,57 +593,124 @@ extratag(Cstring t)
}
/*
* process embedded links and images
/* print out a linky (or fail if it's Not Allowed)
*/
static int
linkylinky(int image, MMIOT *f)
linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
{
int start = mmiottell(f);
Footnote link;
linkytype *tag;
if ( !linkykey(image, &link, f) ) {
mmiotseek(f, start);
return 0;
}
if ( image )
tag = &imaget;
else if ( (f->flags & NO_PSEUDO_PROTO) || (tag = extratag(link.link)) == 0 )
else if ( tag = pseudo(ref->link) ) {
if ( f->flags & (NO_PSEUDO_PROTO|SAFELINK) )
return 0;
}
else if ( (f->flags & SAFELINK) && T(ref->link)
&& (T(ref->link)[0] != '/')
&& !isautoprefix(T(ref->link)) )
/* if SAFELINK, only accept links that are local or
* a well-known protocol
*/
return 0;
else
tag = &linkt;
if ( f->flags & tag-> flags ) {
mmiotseek(f, start);
if ( f->flags & tag->flags )
return 0;
}
if ( tag->link_pfx ) {
Qstring(tag->link_pfx, f);
if ( f->base && (T(link.link)[tag->szpat] == '/') )
puturl(f->base, strlen(f->base), f);
puturl(T(link.link) + tag->szpat, S(link.link) - tag->szpat, f);
if ( tag->kind & IS_URL ) {
if ( f->base && T(ref->link) && (T(ref->link)[tag->szpat] == '/') )
puturl(f->base, strlen(f->base), f, 0);
puturl(T(ref->link) + tag->szpat, S(ref->link) - tag->szpat, f, 0);
}
else
___mkd_reparse(T(ref->link) + tag->szpat, S(ref->link) - tag->szpat, INSIDE_TAG, f);
Qstring(tag->link_sfx, f);
if ( tag->WxH && link.height && link.width ) {
Qprintf(f," height=\"%d\"", link.height);
Qprintf(f, " width=\"%d\"", link.width);
if ( tag->WxH && ref->height && ref->width ) {
Qprintf(f," height=\"%d\"", ref->height);
Qprintf(f, " width=\"%d\"", ref->width);
}
if ( S(link.title) ) {
if ( S(ref->title) ) {
Qstring(" title=\"", f);
___mkd_reparse(T(link.title), S(link.title), INSIDE_TAG, f);
___mkd_reparse(T(ref->title), S(ref->title), INSIDE_TAG, f);
Qchar('"', f);
}
Qstring(tag->text_pfx, f);
___mkd_reparse(T(link.tag), S(link.tag), tag->flags, f);
___mkd_reparse(T(text), S(text), tag->flags, f);
Qstring(tag->text_sfx, f);
}
else
Qwrite(T(link.link) + tag->szpat, S(link.link) - tag->szpat, f);
Qwrite(T(ref->link) + tag->szpat, S(ref->link) - tag->szpat, f);
return 1;
} /* linkyformat */
/*
* process embedded links and images
*/
static int
linkylinky(int image, MMIOT *f)
{
int start = mmiottell(f);
Cstring name;
Footnote key, *ref;
int status = 0;
CREATE(name);
bzero(&key, sizeof key);
if ( linkylabel(f, &name) ) {
if ( peek(f,1) == '(' ) {
pull(f);
if ( linkyurl(f, image, &key) )
status = linkyformat(f, name, image, &key);
}
else {
int goodlink, implicit_mark = mmiottell(f);
if ( eatspace(f) == '[' ) {
pull(f); /* consume leading '[' */
goodlink = linkylabel(f, &key.tag);
}
else {
/* new markdown implicit name syntax doesn't
* require a second []
*/
mmiotseek(f, implicit_mark);
goodlink = !(f->flags & MKD_1_COMPAT);
}
if ( goodlink ) {
if ( !S(key.tag) ) {
DELETE(key.tag);
T(key.tag) = T(name);
S(key.tag) = S(name);
}
if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes),
sizeof key, (stfu)__mkd_footsort) )
status = linkyformat(f, name, image, ref);
}
}
}
DELETE(name);
___mkd_freefootnote(&key);
if ( status == 0 )
mmiotseek(f, start);
return status;
}
@ -706,6 +763,80 @@ forbidden_tag(MMIOT *f)
}
/* Check a string to see if it looks like a mail address
* "looks like a mail address" means alphanumeric + some
* specials, then a `@`, then alphanumeric + some specials,
* but with a `.`
*/
static int
maybe_address(char *p, int size)
{
int ok = 0;
for ( ;size && (isalnum(*p) || strchr("._-+*", *p)); ++p, --size)
;
if ( ! (size && *p == '@') )
return 0;
--size, ++p;
if ( size && *p == '.' ) return 0;
for ( ;size && (isalnum(*p) || strchr("._-+", *p)); ++p, --size )
if ( *p == '.' && size > 1 ) ok = 1;
return size ? 0 : ok;
}
/* The size-length token at cursor(f) is either a mailto:, an
* implicit mailto:, one of the approved url protocols, or just
* plain old text. If it's a mailto: or an approved protocol,
* linkify it, otherwise say "no"
*/
static int
process_possible_link(MMIOT *f, int size)
{
int address= 0;
int mailto = 0;
char *text = cursor(f);
if ( f->flags & DENY_A ) return 0;
if ( (size > 7) && strncasecmp(text, "mailto:", 7) == 0 ) {
/* if it says it's a mailto, it's a mailto -- who am
* I to second-guess the user?
*/
address = 1;
mailto = 7; /* 7 is the length of "mailto:"; we need this */
}
else
address = maybe_address(text, size);
if ( address ) {
Qstring("<a href=\"", f);
if ( !mailto ) {
/* supply a mailto: protocol if one wasn't attached */
mangle("mailto:", 7, f);
}
mangle(text, size, f);
Qstring("\">", f);
mangle(text+mailto, size-mailto, f);
Qstring("</a>", f);
return 1;
}
else if ( isautoprefix(text) ) {
Qstring("<a href=\"", f);
puturl(text,size,f, 0);
Qstring("\">", f);
puturl(text,size,f, 1);
Qstring("</a>", f);
return 1;
}
return 0;
} /* process_possible_link */
/* a < may be just a regular character, the start of an embedded html
* tag, or the start of an <automatic link>. If it's an automatic
@ -716,68 +847,69 @@ forbidden_tag(MMIOT *f)
static int
maybe_tag_or_link(MMIOT *f)
{
char *text;
int c, size, i;
int maybetag=1, maybeaddress=0;
int mailto;
int c, size;
int maybetag = 1;
if ( f->flags & INSIDE_TAG )
return 0;
for ( size=0; ((c = peek(f,size+1)) != '>') && !isspace(c); size++ ) {
if ( ! (c == '/' || isalnum(c) || c == '~') )
maybetag=0;
if ( c == '@' )
maybeaddress=1;
else if ( c == EOF )
for ( size=0; (c = peek(f, size+1)) != '>'; size++) {
if ( c == EOF )
return 0;
else if ( c == '\\' ) {
maybetag=0;
if ( peek(f, size+2) != EOF )
size++;
}
else if ( isspace(c) )
break;
else if ( ! (c == '/' || isalnum(c) ) )
maybetag=0;
}
if ( size == 0 )
return 0;
if ( maybetag || (size >= 3 && strncmp(cursor(f), "!--", 3) == 0) ) {
Qstring(forbidden_tag(f) ? "&lt;" : "<", f);
while ( ((c = peek(f, 1)) != EOF) && (c != '>') )
cputc(pull(f), f);
return 1;
if ( size ) {
if ( maybetag || (size >= 3 && strncmp(cursor(f), "!--", 3) == 0) ) {
Qstring(forbidden_tag(f) ? "&lt;" : "<", f);
while ( ((c = peek(f, 1)) != EOF) && (c != '>') )
cputc(pull(f), f);
return 1;
}
else if ( !isspace(c) && process_possible_link(f, size) ) {
shift(f, size+1);
return 1;
}
}
return 0;
}
if ( f->flags & DENY_A ) return 0;
text = cursor(f);
shift(f, size+1);
for ( i=0; i < SZAUTOPREFIX; i++ )
if ( strncasecmp(text, autoprefix[i], strlen(autoprefix[i])) == 0 ) {
Qstring("<a href=\"", f);
puturl(text,size,f);
Qstring("\">", f);
puturl(text,size,f);
Qstring("</a>", f);
return 1;
}
if ( maybeaddress ) {
/* autolinking means that all inline html is <a href'ified>. A
* autolink url is alphanumerics, slashes, periods, underscores,
* the at sign, colon, and the % character.
*/
static int
maybe_autolink(MMIOT *f)
{
register int c;
int size;
Qstring("<a href=\"", f);
if ( (size > 7) && strncasecmp(text, "mailto:", 7) == 0 )
mailto = 7;
else {
mailto = 0;
/* supply a mailto: protocol if one wasn't attached */
mangle("mailto:", 7, f);
/* greedily scan forward for the end of a legitimate link.
*/
for ( size=0; (c=peek(f, size+1)) != EOF; size++ )
if ( c == '\\' ) {
if ( peek(f, size+2) != EOF )
++size;
}
else if ( isspace(c) || strchr("'\"()[]{}<>`", c) )
break;
mangle(text, size, f);
Qstring("\">", f);
mangle(text+mailto, size-mailto, f);
Qstring("</a>", f);
if ( (size > 1) && process_possible_link(f, size) ) {
shift(f, size);
return 1;
}
shift(f, -(size+1));
return 0;
} /* maybe_tag_or_link */
}
/* smartyquote code that's common for single and double quotes
@ -863,7 +995,7 @@ smartypants(int c, int *flags, MMIOT *f)
{
int i;
if ( f->flags & DENY_SMARTY )
if ( f->flags & (DENY_SMARTY|INSIDE_TAG) )
return 0;
for ( i=0; i < NRSMART; i++)
@ -917,12 +1049,23 @@ text(MMIOT *f)
int rep;
int smartyflags = 0;
while ( (c = pull(f)) != EOF ) {
while (1) {
if ( (f->flags & AUTOLINK) && isalpha(peek(f,1)) )
maybe_autolink(f);
c = pull(f);
if (c == EOF)
break;
if ( smartypants(c, &smartyflags, f) )
continue;
switch (c) {
case 0: break;
case 3: Qstring("<br/>", f);
break;
case '>': if ( tag_text(f) )
Qstring("&gt;", f);
else
@ -966,15 +1109,24 @@ text(MMIOT *f)
case '_':
#if RELAXED_EMPHASIS
/* Underscores don't count if they're in the middle of a word */
if ( (!(f->flags & STRICT))
&& ((isthisspace(f,-1) && isthisspace(f,1))
|| (isthisalnum(f,-1) && isthisalnum(f,1))) ){
if ( !(f->flags & STRICT) && isthisalnum(f,-1)
&& isthisalnum(f,1) ) {
Qchar(c, f);
break;
}
#endif
case '*':
#if RELAXED_EMPHASIS
/* Underscores & stars don't count if they're out in the middle
* of whitespace */
if ( !(f->flags & STRICT) && isthisspace(f,-1)
&& isthisspace(f,1) ) {
Qchar(c, f);
break;
}
/* else fall into the regular old emphasis case */
#endif
case '*': if ( tag_text(f) )
if ( tag_text(f) )
Qchar(c, f);
else {
for (rep = 1; peek(f,1) == c; pull(f) )
@ -1126,6 +1278,106 @@ printheader(Paragraph *pp, MMIOT *f)
}
enum e_alignments { a_NONE, a_CENTER, a_LEFT, a_RIGHT };
static char* alignments[] = { "", " align=\"center\"", " align=\"left\"",
" align=\"right\"" };
typedef STRING(int) Istring;
static int
splat(Line *p, char *block, Istring align, int force, MMIOT *f)
{
int first,
idx = 0,
colno = 0;
Qstring("<tr>\n", f);
while ( idx < S(p->text) ) {
first = idx;
if ( force && (colno >= S(align)-1) )
idx = S(p->text);
else
while ( (idx < S(p->text)) && (T(p->text)[idx] != '|') )
++idx;
Qprintf(f, "<%s%s>",
block,
alignments[ (colno < S(align)) ? T(align)[colno] : a_NONE ]);
___mkd_reparse(T(p->text)+first, idx-first, 0, f);
Qprintf(f, "</%s>\n", block);
idx++;
colno++;
}
if ( force )
while (colno < S(align) ) {
Qprintf(f, "<%s></%s>\n", block, block);
++colno;
}
Qstring("</tr>\n", f);
return colno;
}
static int
printtable(Paragraph *pp, MMIOT *f)
{
/* header, dashes, then lines of content */
Line *hdr, *dash, *body;
Istring align;
int start;
int hcols;
char *p;
if ( !(pp->text && pp->text->next && pp->text->next->next) )
return 0;
hdr = pp->text;
dash= hdr->next;
body= dash->next;
/* first figure out cell alignments */
CREATE(align);
for (p=T(dash->text), start=0; start < S(dash->text); ) {
char first, last;
int end;
last=first=0;
for (end=start ; (end < S(dash->text)) && p[end] != '|'; ++ end ) {
if ( !isspace(p[end]) ) {
if ( !first) first = p[end];
last = p[end];
}
}
EXPAND(align) = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT)
: (( last == ':') ? a_RIGHT : a_NONE );
start = 1+end;
}
Qstring("<table>\n", f);
Qstring("<thead>\n", f);
hcols = splat(hdr, "th", align, 0, f);
Qstring("</thead>\n", f);
if ( hcols < S(align) )
S(align) = hcols;
else
while ( hcols > S(align) )
EXPAND(align) = a_NONE;
Qstring("<tbody>\n", f);
for ( ; body; body = body->next)
splat(body, "td", align, 1, f);
Qstring("</tbody>\n", f);
Qstring("</table>\n", f);
DELETE(align);
return 1;
}
static int
printblock(Paragraph *pp, MMIOT *f)
{
@ -1138,10 +1390,10 @@ printblock(Paragraph *pp, MMIOT *f)
if ( S(t->text) > 2 && T(t->text)[S(t->text)-2] == ' '
&& T(t->text)[S(t->text)-1] == ' ') {
push(T(t->text), S(t->text)-2, f);
push("<br/>\n", 6, f);
push("\003\n", 2, f);
}
else {
___mkd_tidy(t);
___mkd_tidy(&t->text);
push(T(t->text), S(t->text), f);
if ( t->next )
push("\n", 1, f);
@ -1232,6 +1484,7 @@ definitionlist(Paragraph *p, MMIOT *f)
}
htmlify(p->down, "dd", p->ident, f);
Qchar('\n', f);
}
Qstring("</dl>", f);
@ -1303,6 +1556,14 @@ display(Paragraph *p, MMIOT *f)
printheader(p, f);
break;
case TABLE:
printtable(p, f);
break;
case SOURCE:
htmlify(p->down, 0, 0, f);
break;
default:
printblock(p, f);
break;
@ -1311,29 +1572,6 @@ display(Paragraph *p, MMIOT *f)
}
/*
* dump out stylesheet sections.
*/
static int
stylesheets(Paragraph *p, FILE *f)
{
Line* q;
for ( ; p ; p = p->next ) {
if ( p->typ == STYLE ) {
for ( q = p->text; q ; q = q->next )
if ( fwrite(T(q->text), S(q->text), 1, f) == 1 )
putc('\n', f);
else
return EOF;
}
if ( p->down && (stylesheets(p->down, f) == EOF) )
return EOF;
}
return 0;
}
/* return a pointer to the compiled markdown
* document.
*/
@ -1352,36 +1590,3 @@ mkd_document(Document *p, char **res)
return EOF;
}
/* public interface for ___mkd_reparse()
*/
int
mkd_text(char *bfr, int size, FILE *output, int flags)
{
MMIOT f;
___mkd_initmmiot(&f, 0);
f.flags = flags & USER_FLAGS;
___mkd_reparse(bfr, size, 0, &f);
___mkd_emblock(&f);
if ( flags & CDATA_OUTPUT )
___mkd_xml(T(f.out), S(f.out), output);
else
fwrite(T(f.out), S(f.out), 1, output);
___mkd_freemmiot(&f, 0);
return 0;
}
/* dump any embedded styles
*/
int
mkd_style(Document *d, FILE *f)
{
if ( d && d->compiled )
return stylesheets(d->code, f);
return EOF;
}

discount-1.3.4/main.c → discount-1.5.5/main.c View File

@ -46,12 +46,16 @@ static struct {
{ "links", 1, MKD_NOLINKS },
{ "relax", 1, MKD_STRICT },
{ "strict", 0, MKD_STRICT },
{ "tables", 1, MKD_NOTABLES },
{ "header", 1, MKD_NOHEADER },
{ "html", 1, MKD_NOHTML },
{ "ext", 1, MKD_NO_EXT },
{ "cdata", 0, MKD_CDATA },
{ "pants", 1, MKD_NOPANTS },
{ "smarty", 1, MKD_NOPANTS },
{ "toc", 0, MKD_TOC },
{ "autolink",0, MKD_AUTOLINK },
{ "safelink",0, MKD_SAFELINK },
{ "1.0", 0, MKD_1_COMPAT },
} ;
@ -102,14 +106,15 @@ main(int argc, char **argv)
int flags = 0;
int debug = 0;
int toc = 0;
int use_mkd_text = 0;
int use_mkd_line = 0;
char *text = 0;
char *ofile = 0;
char *urlbase = 0;
char *q = getenv("MARKDOWN_FLAGS");
char *q;
MMIOT *doc;
if ( q ) flags = strtol(q, 0, 0);
if ( q = getenv("MARKDOWN_FLAGS") )
flags = strtol(q, 0, 0);
pgm = basename(argv[0]);
opterr = 1;
@ -127,7 +132,7 @@ main(int argc, char **argv)
case 'f': set(&flags, optarg);
break;
case 't': text = optarg;
use_mkd_text = 1;
use_mkd_line = 1;
break;
case 'T': toc = 1;
break;
@ -142,17 +147,18 @@ main(int argc, char **argv)
exit(1);
}
break;
default: fprintf(stderr, "usage: %s [-dV] [-burl-base]"
" [-F flags] [-f{+-}setting]"
" [-o file] [file]\n", pgm);
default: fprintf(stderr, "usage: %s [-dTV] [-b url-base]"
" [-F bitmap] [-f {+-}flags]"
" [-o ofile] [-s text]"
" [-t text] [file]\n", pgm);
exit(1);
}
}
argc -= optind;
argv += optind;
if ( use_mkd_text )
rc = mkd_text( text, strlen(text), stdout, flags);
if ( use_mkd_line )
rc = mkd_generateline( text, strlen(text), stdout, flags);
else {
if ( text ) {
if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {

discount-1.3.4/makepage.c → discount-1.5.5/makepage.c View File


discount-1.3.4/markdown.1.in → discount-1.5.5/markdown.1.in View File

@ -9,9 +9,11 @@
.Sh SYNOPSIS
.Nm
.Op Fl d
.Op Fl T
.Op Fl V
.Op Fl b Ar url-base
.Op Fl F Pa bitmap
.Op Fl f Ar options
.Op Fl f Ar flags
.Op Fl o Pa file
.Op Fl s Pa text
.Op Fl t Pa text
@ -28,10 +30,14 @@ to stdout.
.Pp
The options are as follows:
.Bl -tag -width "-o file"
.It Fl b Ar url-base
Links in source begining with / will be prefixed with
.Ar url-base
in the output.
.It Fl d
Instead of writing the html file, dump a parse
tree to stdout.
.It Fl f options
.It Fl f Ar flags
Set or clear various translation flags. The flags
are in a comma-delimited list, with an optional
.Ar +
@ -49,6 +55,8 @@ embedded html.
Generate valid XML output.
.It Ar noheader
Do not process pandoc headers.
.It Ar notables
Do not process Markdown Extra-style tables.
.It Ar tabstops
Use markdown-standard 4-space tabstops.
@STRICT@.It Ar strict

discount-1.3.4/markdown.3 → discount-1.5.5/markdown.3 View File

@ -16,8 +16,6 @@ Markdown
.Fn *mkd_string "char *string" "int size"
.Ft int
.Fn markdown "MMIOT *doc" "FILE *output" "int flags"
.Ft int
.Fn mkd_text "char *string" "int size" "FILE *output" "int flags"
.Sh DESCRIPTION
These functions
convert
@ -28,16 +26,6 @@ processes an entire document, while
.Fn mkd_text
processes a single string.
.Pp
The
.Fn markdown
function expects to recieve a preprocessed text from the
.Fn mkd_in
or
.Fn mkd_string
functions, while
.Fn mkd_text
treats your input text as a single paragraph of markup.
.Pp
To process a file, you pass a FILE* to
.Fn mkd_in ,
and if it returns a nonzero value you pass that in to
@ -54,11 +42,9 @@ and pass its return value to
.Fn markdown.
.Pp
.Fn Markdown
and
.Fn mkd_text
accept the following flag values (or-ed together if needed)
to restrict how they process their input:
.Bl -tag -width MKD_NOIMAGE -compact
accepts the following flag values (or-ed together if needed)
to restrict how it processes input:
.Bl -tag -width MKD_SAFELINK -compact
.It Ar MKD_NOIMAGE
Do not process `![]' and
remove
@ -73,10 +59,10 @@ Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
.It Ar MKD_STRICT
Disable superscript and relaxed emphasis processing (if they are configured;
otherwise it's a no-op.)
.It Ar MKD_QUOT
Expand
.Ar \&"
to \&&quot;.
.\" .It Ar MKD_QUOT
.\" Expand
.\" .Ar \&"
.\" to \&&quot;.
.It Ar MKD_NOHEADER
Do not attempt to parse any Pandoc-style headers.
.It Ar MKD_TABSTOP
@ -94,13 +80,22 @@ functions.
.It Ar MKD_1_COMPAT
MarkdownTest_1.0 compatability flag; trim trailing spaces from the
first line of code blocks and disable implicit reference links.
.It Ar MKD_AUTOLINK
Greedily urlify links -- if
.Em MKD_AUTOLINK
is set, urls will be converted into hyperlinks even if they
aren't encased in
.Em <> .
.It Ar MKD_SAFELINK
Don't make hyperlinks from
.Em [][]
links that have unknown url types.
.It Ar MKD_NOTABLES
Don't process tables.
.El
.Sh RETURN VALUES
The functions
.Fn markdown
and
.Fn mkd_text
return 0 on success, 1 on failure.
returns 0 on success, 1 on failure.
The
.Fn mkd_in
and
@ -109,6 +104,7 @@ functions return a MMIOT* on success, null on failure.
.Sh SEE ALSO
.Xr markdown 1 ,
.Xr mkd-functions 3 ,
.Xr mkd-line 3 ,
.Xr markdown 7 ,
.Xr mkd-extensions 7 ,
.Xr mmap 2 .
@ -120,8 +116,6 @@ Error handling is minimal at best.
The
.Ar MMIOT
created by
.Fn mkd_text
and
.Fn mkd_string
is deleted by the
.Nm

discount-1.3.4/markdown.7 → discount-1.5.5/markdown.7 View File


discount-1.3.4/markdown.c → discount-1.5.5/markdown.c View File

@ -21,10 +21,12 @@
*/
struct kw {
char *id;
int siz;
int size;
int selfclose;
} ;
#define KW(x) { x, sizeof(x)-1 }
#define KW(x) { x, sizeof(x)-1, 0 }
#define SC(x) { x, sizeof(x)-1, 1 }
static struct kw blocktags[] = { KW("!--"), KW("STYLE"), KW("SCRIPT"),
KW("ADDRESS"), KW("BDO"), KW("BLOCKQUOTE"),
@ -33,7 +35,8 @@ static struct kw blocktags[] = { KW("!--"), KW("STYLE"), KW("SCRIPT"),
KW("H6"), KW("LISTING"), KW("NOBR"),
KW("UL"), KW("P"), KW("OL"), KW("DL"),
KW("PLAINTEXT"), KW("PRE"), KW("TABLE"),
KW("WBR"), KW("XMP"), KW("HR"), KW("BR") };
KW("WBR"), KW("XMP"), SC("HR"), SC("BR"),
KW("IFRAME"), KW("MAP") };
#define SZTAGS (sizeof blocktags / sizeof blocktags[0])
#define MAXTAG 11 /* sizeof "BLOCKQUOTE" */
@ -47,9 +50,9 @@ typedef ANCHOR(Paragraph) ParagraphRoot;
static int
casort(struct kw *a, struct kw *b)
{
if ( a->siz != b->siz )
return a->siz - b->siz;
return strncasecmp(a->id, b->id, b->siz);
if ( a->size != b->size )
return a->size - b->size;
return strncasecmp(a->id, b->id, b->size);
}
@ -125,14 +128,14 @@ skipempty(Line *p)
void
___mkd_tidy(Line *t)
___mkd_tidy(Cstring *t)
{
while ( S(t->text) && isspace(T(t->text)[S(t->text)-1]) )
--S(t->text);
while ( S(*t) && isspace(T(*t)[S(*t)-1]) )
--S(*t);
}
static char *
static struct kw *
isopentag(Line *p)
{
int i=0, len;
@ -154,57 +157,85 @@ isopentag(Line *p)
;
key.id = T(p->text)+1;
key.siz = i-1;
key.size = i-1;
if ( ret = bsearch(&key,blocktags,SZTAGS,sizeof key, (stfu)casort))
return ret->id;
if ( ret = bsearch(&key, blocktags, SZTAGS, sizeof key, (stfu)casort))
return ret;
return 0;
}
static int
selfclose(Line *t, char *tag)
{
char *q = T(t->text);
int siz = strlen(tag);
typedef struct _flo {
Line *t;
int i;
} FLO;
if ( strcasecmp(tag, "HR") == 0 || strcasecmp(tag, "BR") == 0 )
/* <HR> and <BR> are self-closing block-level tags,
*/
return 1;
i = S(t->text) - (siz + 3);
/* we specialcase start and end tags on the same line.
*/
return ( i > 0 ) && (q[i] == '<') && (q[i+1] == '/')
&& (q[i+2+siz] == '>')
&& (strncasecmp(&q[i+2], tag, siz) == 0);
static int
flogetc(FLO *f)
{
if ( f && f->t ) {
if ( f->i < S(f->t->text) )
return T(f->t->text)[f->i++];
f->t = f->t->next;
f->i = 0;
return flogetc(f);
}
return EOF;
}
static Line *
htmlblock(Paragraph *p, char *tag)
htmlblock(Paragraph *p, struct kw *tag)
{
Line *t = p->text, *ret;
int closesize;
char close[MAXTAG+4];
Line *ret;
FLO f = { p->text, 0 };
int c;
int i, closing, depth=0;
if ( selfclose(t, tag) || (strlen(tag) >= MAXTAG) ) {
ret = t->next;
t->next = 0;
if ( tag->selfclose || (tag->size >= MAXTAG) ) {
ret = f.t->next;
f.t->next = 0;
return ret;
}
closesize = sprintf(close, "</%s>", tag);
for ( ; t ; t = t->next) {
if ( strncasecmp(T(t->text), close, closesize) == 0 ) {
ret = t->next;
t->next = 0;
return ret;
while ( (c = flogetc(&f)) != EOF ) {
if ( c == '<' ) {
/* tag? */
c = flogetc(&f);
if ( c == '!' ) { /* comment? */
if ( flogetc(&f) == '-' && flogetc(&f) == '-' ) {
/* yes */
while ( (c = flogetc(&f)) != EOF ) {
if ( c == '-' && flogetc(&f) == '-'
&& flogetc(&f) == '>')
/* consumed whole comment */
break;
}
}
}
else {
if ( closing = (c == '/') ) c = flogetc(&f);
for ( i=0; i < tag->size; c=flogetc(&f) ) {
if ( tag->id[i++] != toupper(c) )
break;
}
if ( (i == tag->size) && !isalnum(c) ) {
depth = depth + (closing ? -1 : 1);
if ( depth == 0 ) {
while ( c != EOF && c != '>' ) {
/* consume trailing gunk in close tag */
c = flogetc(&f);
}
ret = f.t->next;
f.t->next = 0;
return ret;
}
}
}
}
}
return 0;
@ -212,7 +243,7 @@ htmlblock(Paragraph *p, char *tag)
static Line *
comment(Paragraph *p, char *key)
comment(Paragraph *p)
{
Line *t, *ret;
@ -228,6 +259,30 @@ comment(Paragraph *p, char *key)
}
/* tables look like
* header|header{|header}
* ------|------{|......}
* {body lines}
*/
static int
istable(Line *t)
{
char *p;
Line *dashes = t->next;
/* two lines, first must contain | */
if ( !(dashes && memchr(T(t->text), '|', S(t->text))) )
return 0;
/* second line must be only whitespace, |, -, or - */
for ( p = T(dashes->text)+S(dashes->text)-1; p >= T(dashes->text); --p)
if ( ! ((*p == '|') || (*p == ':') || (*p == '-') || isspace(*p)) )
return 0;
return 1;
}
/* footnotes look like ^<whitespace>{0,3}[stuff]: <content>$
*/
static int
@ -307,7 +362,7 @@ ishdr(Line *t, int *htyp)
/* ANY leading `#`'s make this into an ETX header
*/
if ( i ) {
if ( i && (i < S(t->text) || i > 1) ) {
*htyp = ETX;
return 1;
}
@ -523,17 +578,17 @@ szmarkerclass(char *p)
* marker %[kind:]name%
*/
static int
isdivmarker(Line *p)
isdivmarker(Line *p, int start)
{
#if DIV_QUOTE
char *s = T(p->text);
int len = S(p->text);
int i;
if ( !(len && s[0] == '%' && s[len-1] == '%') ) return 0;
if ( !(len && s[start] == '%' && s[len-1] == '%') ) return 0;
i = szmarkerclass(s+1);
--len;
i = szmarkerclass(s+start+1)+start;
len -= start+1;
while ( ++i < len )
if ( !isalnum(s[i]) )
@ -570,13 +625,15 @@ quoteblock(Paragraph *p)
t->dle = mkd_firstnonblank(t);
}
if ( !(q = skipempty(t->next)) || ((q != t->next) && !isquote(q)) ) {
q = skipempty(t->next);
if ( (q == 0) || ((q != t->next) && (!isquote(q) || isdivmarker(q,1))) ) {
___mkd_freeLineRange(t, q);
t = q;
break;
}
}
if ( isdivmarker(p->text) ) {
if ( isdivmarker(p->text,0) ) {
char *prefix = "class";
int i;
@ -587,7 +644,7 @@ quoteblock(Paragraph *p)
/* and this would be an "%id:" prefix */
prefix="id";
if ( p->ident = malloc(4+i+S(q->text)) )
if ( p->ident = malloc(4+strlen(prefix)+S(q->text)) )
sprintf(p->ident, "%s=\"%.*s\"", prefix, S(q->text)-(i+2),
T(q->text)+(i+1) );
@ -597,6 +654,25 @@ quoteblock(Paragraph *p)
}
/*
* A table block starts with a table header (see istable()), and continues
* until EOF or a line that /doesn't/ contain a |.
*/
static Line *
tableblock(Paragraph *p)
{
Line *t, *q;
for ( t = p->text; t && (q = t->next); t = t->next ) {
if ( !memchr(T(q->text), '|', S(q->text)) ) {
t->next = 0;
return q;
}
}
return 0;
}
static Paragraph *Pp(ParagraphRoot *, Line *, int);
static Paragraph *compile(Line *, int, MMIOT *);
@ -628,7 +704,7 @@ listitem(Paragraph *p, int indent)
* need any indentation
*/
if ( q != t->next ) {
if (q->dle < 4) {
if (q->dle < indent) {
q = t->next;
t->next = 0;
return q;
@ -653,9 +729,10 @@ listblock(Paragraph *top, int trim, MMIOT *f)
{
ParagraphRoot d = { 0, 0 };
Paragraph *p;
Line *q = top->text, *text;
Line *label;
int para = 0;
Line *q = top->text, *text, *label;
int isdl = (top->typ == DL),
para = 0,
ltype;
while (( text = q )) {
if ( top->typ == DL ) {
@ -679,7 +756,8 @@ listblock(Paragraph *top, int trim, MMIOT *f)
if ( para && (top->typ != DL) && p->down ) p->down->align = PARA;
if ( !(q = skipempty(text)) || (islist(q, &trim) == 0) )
if ( !(q = skipempty(text)) || ((ltype = islist(q, &trim)) == 0)
|| (isdl != (ltype == DL)) )
break;
if ( para = (q != text) ) {
@ -809,6 +887,64 @@ consume(Line *ptr, int *eaten)
}
/*
* top-level compilation; break the document into
* style, html, and source blocks with footnote links
* weeded out.
*/
static Paragraph *
compile_document(Line *ptr, MMIOT *f)
{
ParagraphRoot d = { 0, 0 };
ANCHOR(Line) source = { 0, 0 };
Paragraph *p = 0;
struct kw *tag;
int eaten;
while ( ptr ) {
if ( !(f->flags & DENY_HTML) && (tag = isopentag(ptr)) ) {
/* If we encounter a html/style block, compile and save all
* of the cached source BEFORE processing the html/style.
*/
if ( T(source) ) {
E(source)->next = 0;
p = Pp(&d, 0, SOURCE);
p->down = compile(T(source), 1, f);
T(source) = E(source) = 0;
}
p = Pp(&d, ptr, strcmp(tag->id, "STYLE") == 0 ? STYLE : HTML);
if ( strcmp(tag->id, "!--") == 0 )
ptr = comment(p);
else
ptr = htmlblock(p, tag);
}
else if ( isfootnote(ptr) ) {
/* footnotes, like cats, sleep anywhere; pull them
* out of the input stream and file them away for
* later processing
*/
ptr = consume(addfootnote(ptr, f), &eaten);
}
else {
/* source; cache it up to wait for eof or the
* next html/style block
*/
ATTACH(source,ptr);
ptr = ptr->next;
}
}
if ( T(source) ) {
/* if there's any cached source at EOF, compile
* it now.
*/
E(source)->next = 0;
p = Pp(&d, 0, SOURCE);
p->down = compile(T(source), 1, f);
}
return T(d);
}
/*
* break a collection of markdown input into
* blocks of lists, code, html, and text to
@ -819,29 +955,22 @@ compile(Line *ptr, int toplevel, MMIOT *f)
{
ParagraphRoot d = { 0, 0 };
Paragraph *p = 0;
char *key;
Line *r;
int para = toplevel;
int blocks = 0;
int hdr_type, list_type, indent;
ptr = consume(ptr, &para);
while ( ptr ) {
if ( toplevel && !(f->flags & DENY_HTML) && (key = isopentag(ptr)) ) {
p = Pp(&d, ptr, strcmp(key, "STYLE") == 0 ? STYLE : HTML);
if ( strcmp(key, "!--") == 0 )
ptr = comment(p, key);
else
ptr = htmlblock(p, key);
}
else if ( iscode(ptr) ) {
if ( iscode(ptr) ) {
p = Pp(&d, ptr, CODE);
if ( f->flags & MKD_1_COMPAT) {
/* HORRIBLE STANDARDS KLUDGE: the first line of every block
* has trailing whitespace trimmed off.
*/
___mkd_tidy(p->text);
___mkd_tidy(&p->text->text);
}
ptr = codeblock(p);
@ -866,9 +995,9 @@ compile(Line *ptr, int toplevel, MMIOT *f)
p = Pp(&d, ptr, HDR);
ptr = headerblock(p, hdr_type);
}
else if ( toplevel && (isfootnote(ptr)) ) {
ptr = consume(addfootnote(ptr, f), &para);
continue;
else if ( istable(ptr) && !(f->flags & (STRICT|NOTABLES)) ) {
p = Pp(&d, ptr, TABLE);
ptr = tableblock(p);
}
else {
p = Pp(&d, ptr, MARKUP);
@ -878,7 +1007,8 @@ compile(Line *ptr, int toplevel, MMIOT *f)
if ( (para||toplevel) && !p->align )
p->align = PARA;
para = toplevel;
blocks++;
para = toplevel || (blocks > 1);
ptr = consume(ptr, &para);
if ( para && !p->align )
@ -929,7 +1059,7 @@ mkd_compile(Document *doc, int flags)
initialize();
doc->code = compile(T(doc->content), 1, doc->ctx);
doc->code = compile_document(T(doc->content), doc->ctx);
qsort(T(*doc->ctx->footnotes), S(*doc->ctx->footnotes),
sizeof T(*doc->ctx->footnotes)[0],
(stfu)__mkd_footsort);

discount-1.3.4/markdown.h → discount-1.5.5/markdown.h View File

@ -11,6 +11,7 @@ typedef struct footnote {
Cstring link; /* what this footnote points to */
Cstring title; /* what it's called (TITLE= attribute) */
int height, width; /* dimensions (for image link) */
int dealloc; /* deallocation needed? */
} Footnote;
/* each input line is read into a Line, which contains the line,
@ -36,7 +37,7 @@ typedef struct paragraph {
char *ident; /* %id% tag for QUOTE */
enum { WHITESPACE=0, CODE, QUOTE, MARKUP,
HTML, STYLE, DL, UL, OL, AL, LISTITEM,
HDR, HR } typ;
HDR, HR, TABLE, SOURCE } typ;
enum { IMPLICIT=0, PARA, CENTER} align;
int hnumber; /* <Hn> for typ == HDR */
} Paragraph;
@ -73,9 +74,12 @@ typedef struct mmiot {
#define INSIDE_TAG 0x0020
#define NO_PSEUDO_PROTO 0x0040
#define CDATA_OUTPUT 0x0080
#define NOTABLES 0x0400
#define TOC 0x1000
#define MKD_1_COMPAT 0x2000
#define USER_FLAGS 0xF0FF
#define AUTOLINK 0x4000
#define SAFELINK 0x8000
#define USER_FLAGS 0xFCFF
#define EMBEDDED DENY_A|DENY_IMG|NO_PSEUDO_PROTO|CDATA_OUTPUT
char *base;
} MMIOT;
@ -104,9 +108,15 @@ extern int mkd_firstnonblank(Line *);
extern int mkd_compile(Document *, int);
extern int mkd_document(Document *, char **);
extern int mkd_generatehtml(Document *, FILE *);
extern int mkd_style(Document *, FILE *);
extern int mkd_css(Document *, char **);
extern int mkd_generatecss(Document *, FILE *);
#define mkd_style mkd_generatecss
extern int mkd_xml(char *, int , char **);
extern int mkd_generatexml(char *, int, FILE *);
extern void mkd_cleanup(Document *);
extern int mkd_text(char *, int, FILE*, int);
extern int mkd_line(char *, int, char **, int);
extern int mkd_generateline(char *, int, FILE*, int);
#define mkd_text mkd_generateline
extern void mkd_basename(Document*, char *);
extern void mkd_string_to_anchor(char*,int, void(*)(int,void*), void*);
@ -123,6 +133,7 @@ extern Document *mkd_string(char*,int, int);
extern void ___mkd_freeLine(Line *);
extern void ___mkd_freeLines(Line *);
extern void ___mkd_freeParagraph(Paragraph *);
extern void ___mkd_freefootnote(Footnote *);
extern void ___mkd_freefootnotes(MMIOT *);
extern void ___mkd_initmmiot(MMIOT *, void *);
extern void ___mkd_freemmiot(MMIOT *, void *);
@ -130,6 +141,6 @@ extern void ___mkd_freeLineRange(Line *, Line *);
extern void ___mkd_xml(char *, int, FILE *);
extern void ___mkd_reparse(char *, int, int, MMIOT*);
extern void ___mkd_emblock(MMIOT*);
extern void ___mkd_tidy(Line *);
extern void ___mkd_tidy(Cstring *);
#endif/*_MARKDOWN_D*/

discount-1.3.4/mkd-extensions.7 → discount-1.5.5/mkd-extensions.7 View File

@ -44,6 +44,13 @@ is written
to the output. The
.Ar "alt text"
is discarded.
.It Ar abbr:
The
.Ar "alt text"
is marked up and written to the output, wrapped with
.Em "<abbr title="abbr">
and
.Em "</abbr>" .
.El
.Ss Pandoc headers
If markdown was configured with
@ -122,6 +129,40 @@ will produce:
<li>list</li>
</ol>
.fi
.Ss tables
.Ar PHP Markdown Extra -style
tables are supported; input of the form
.nf
header|header
------|------
text | text
.fi
will produce:
.nf
<table>
<thead>
<tr>
<th>header</th>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>text</td>
<td>text</td>
</tr>
</tbody>
</table>
.fi
The dashed line can also contain
.Em :
characters for formatting; if a
.Em :
is at the start of a column, it tells
.Nm discount
to align the cell contents to the left; if it's at the end, it
aligns right, and if there's one at the start and at the
end, it centers.
.Sh AUTHOR
David Parsons
.%T http://www.pell.portland.or.us/~orc/
@ -129,6 +170,9 @@ David Parsons
.Xr markdown 1 ,
.Xr markdown 3 ,
.Xr mkd-functions 3 ,
.Xr mkd-line 3 ,
.Xr mkd-extensions 7 .
.Pp
.%T http://daringfireball.net/projects/markdown
.Pp
.%T http://michelf.com/projects/php-markdown

discount-1.3.4/mkd-functions.3 → discount-1.5.5/mkd-functions.3 View File

@ -13,7 +13,9 @@ Markdown
.Ft int
.Fn mkd_compile "MMIOT *document" "int flags"
.Ft int
.Fn mkd_style "MMIOT *document" "FILE *output"
.Fn mkd_css "MMIOT *document" "char **doc"
.Ft int
.Fn mkd_generatecss "MMIOT *document" "FILE *output"
.Ft int
.Fn mkd_document "MMIOT *document" "char **doc"
.Ft int
@ -64,19 +66,23 @@ sections.
.Pp
Once compiled, the document can be examined and written
by the
.Fn mkd_style ,
.Fn mkd_css ,
.Fn mkd_document ,
.Fn mkd_generatecss ,
.Fn mkd_generatehtml ,
.Fn mkd_toc ,
.Fn mkd_generatetoc ,
.Fn mkd_toc ,
.Fn mkd_xhtmlpage ,
.Fn mkd_doc_title ,
.Fn mkd_doc_author ,
and
.Fn mkd_doc_date
functions.
The
.Fn mkd_style
.Pp
.Fn mkd_css
allocates a string and populates it with any \<style\> sections
provided in the document,
.Fn mkd_generatecss
writes any \<style\> sections to the output,
.Fn mkd_document
points
@ -164,6 +170,7 @@ return 0 on success, -1 on failure.
.Sh SEE ALSO
.Xr markdown 1 ,
.Xr markdown 3 ,
.Xr mkd-line 3 ,
.Xr markdown 7 ,
.Xr mkd-extensions 7 ,
.Xr mmap 2 .

+ 41
- 0
discount-1.5.5/mkd-line.3 View File

@ -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.

discount-1.3.4/mkd2html.c → discount-1.5.5/mkd2html.c View File

@ -162,7 +162,7 @@ char **argv;
if ( h ) {
fprintf(output," <title>");
mkd_text(h, strlen(h), output, 0);
mkd_generateline(h, strlen(h), output, 0);
fprintf(output, "</title>\n");
}
for ( i=0; i < S(headers); i++ )

discount-1.3.4/mkdio.c → discount-1.5.5/mkdio.c View File

@ -113,7 +113,7 @@ populate(getc_func getc, void* ctx, int flags)
queue(a, &line);
S(line) = 0;
}
else
else if ( isprint(c) || isspace(c) || (c & 0x80) )
EXPAND(line) = c;
}
@ -193,7 +193,7 @@ mkd_generatehtml(Document *p, FILE *output)
if ( (szdoc = mkd_document(p, &doc)) != EOF ) {
if ( p->ctx->flags & CDATA_OUTPUT )
___mkd_xml(doc, szdoc, output);
mkd_generatexml(doc, szdoc, output);
else
fwrite(doc, szdoc, 1, output);
putc('\n', output);
@ -230,12 +230,74 @@ mkd_basename(Document *document, char *base)
void
mkd_string_to_anchor(char *s, int len, void(*outchar)(int,void*), void *out)
{
for ( ; len-- > 0; ++s ) {
if ( *s == ' ' || *s == '&' || *s == '<' || *s == '"' )
unsigned char c;
for ( ; len-- > 0; ) {
c = *s++;
if ( c == ' ' || c == '&' || c == '<' || c == '"' )
(*outchar)('+', out);
else if ( isalnum(*s) || ispunct(*s) )
(*outchar)(*s, out);
else if ( isalnum(c) || ispunct(c) || (c & 0x80) )
(*outchar)(c, out);
else
(*outchar)('~',out);
}
}
/* ___mkd_reparse() a line
*/
static void
mkd_parse_line(char *bfr, int size, MMIOT *f, int flags)
{
___mkd_initmmiot(f, 0);
f->flags = flags & USER_FLAGS;
___mkd_reparse(bfr, size, 0, f);
___mkd_emblock(f);
}
/* ___mkd_reparse() a line, returning it in malloc()ed memory
*/
int
mkd_line(char *bfr, int size, char **res, int flags)
{
MMIOT f;
int len;
mkd_parse_line(bfr, size, &f, flags);
if ( len = S(f.out) ) {
/* kludge alert; we know that T(f.out) is malloced memory,
* so we can just steal it away. This is awful -- there
* should be an opaque method that transparently moves
* the pointer out of the embedded Cstring.
*/
*res = T(f.out);
T(f.out) = 0;
S(f.out) = 0;
}
else {
*res = 0;
len = EOF;
}
___mkd_freemmiot(&f, 0);
return len;
}
/* ___mkd_reparse() a line, writing it to a FILE
*/
int
mkd_generateline(char *bfr, int size, FILE *output, int flags)
{
MMIOT f;
mkd_parse_line(bfr, size, &f, flags);
if ( flags & CDATA_OUTPUT )
mkd_generatexml(T(f.out), S(f.out), output);
else
fwrite(T(f.out), S(f.out), 1, output);
___mkd_freemmiot(&f, 0);
return 0;
}

discount-1.3.4/mkdio.h → discount-1.5.5/mkdio.h View File

@ -15,19 +15,15 @@ void mkd_basename(MMIOT*,char*);
/* compilation, debugging, cleanup
*/
int mkd_compile(MMIOT*, int);
int mkd_generatehtml(MMIOT*,FILE*);
int mkd_generatetoc(MMIOT*,FILE*);
int mkd_xhtmlpage(MMIOT*,int,FILE*);
int mkd_cleanup(MMIOT*);
/* markup functions
*/
int mkd_text(char *, int, FILE*, int);
int mkd_style(MMIOT*, FILE*);
int mkd_dump(MMIOT*, FILE*, int, char*);
int markdown(MMIOT*, FILE*, int);
void mkd_basename(MMIOT*,char*);
int mkd_line(char *, int, char **, int);
void mkd_string_to_anchor(char *, int, int (*)(int,void*), void*);
int mkd_xhtmlpage(MMIOT*,int,FILE*);
/* header block access
*/
@ -38,6 +34,19 @@ char* mkd_doc_date(MMIOT*);
/* compiled data access
*/
int mkd_document(MMIOT*, char**);
int mkd_toc(MMIOT*, char**);
int mkd_css(MMIOT*, char **);
int mkd_xml(char *, int, char **);
/* write-to-file functions
*/
int mkd_generatehtml(MMIOT*,FILE*);
int mkd_generatetoc(MMIOT*,FILE*);
int mkd_generatexml(char *, int,FILE*);
int mkd_generatecss(MMIOT*,FILE*);
#define mkd_style mkd_generatecss
int mkd_generateline(char *, int, FILE*, int);
#define mkd_text mkd_generateline
/* version#.
*/
@ -50,11 +59,15 @@ extern char markdown_version[];
#define MKD_NOPANTS 0x0004 /* don't run smartypants() */
#define MKD_NOHTML 0x0008 /* don't allow raw html through AT ALL */
#define MKD_STRICT 0x0010 /* disable SUPERSCRIPT, RELAXED_EMPHASIS */
#define MKD_TAGTEXT 0x0020 /* don't expand `_` and `*` */
#define MKD_TAGTEXT 0x0020 /* process text inside an html tag; no
* <em>, no <bold>, no html or [] expansion */
#define MKD_NO_EXT 0x0040 /* don't allow pseudo-protocols */
#define MKD_CDATA 0x0080 /* generate code for xml ![CDATA[...]] */
#define MKD_NOTABLES 0x0400 /* disallow tables */
#define MKD_TOC 0x1000 /* do table-of-contents processing */
#define MKD_1_COMPAT 0x2000 /* compatability with MarkdownTest_1.0 */
#define MKD_AUTOLINK 0x4000 /* make http://foo.com link even without <>s */
#define MKD_SAFELINK 0x8000 /* paranoid check for link protocol */
#define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
/* special flags for mkd_in() and mkd_string()

discount-1.3.4/resource.c → discount-1.5.5/resource.c View File

@ -55,6 +55,17 @@ ___mkd_freeParagraph(Paragraph *p)
}
/* bye bye footnote.
*/
void
___mkd_freefootnote(Footnote *f)
{
DELETE(f->tag);
DELETE(f->link);
DELETE(f->title);
}
/* bye bye footnotes.
*/
void
@ -63,11 +74,8 @@ ___mkd_freefootnotes(MMIOT *f)
int i;
if ( f->footnotes ) {
for (i=0; i < S(*f->footnotes); i++) {
DELETE(T(*f->footnotes)[i].tag);
DELETE(T(*f->footnotes)[i].link);
DELETE(T(*f->footnotes)[i].title);
}
for (i=0; i < S(*f->footnotes); i++)
___mkd_freefootnote( &T(*f->footnotes)[i] );
DELETE(*f->footnotes);
free(f->footnotes);
}
@ -145,25 +153,3 @@ mkd_cleanup(Document *doc)
free(doc);
}
}
/* write output in XML format
*/
void
___mkd_xml(char *p, int size, FILE *out)
{
char c;
while ( size-- > 0 ) {
if ( !isascii(c = *p++) )
continue;
switch (c) {
case '<': fputs("&lt;", out); break;
case '>': fputs("&gt;", out); break;
case '&': fputs("&amp;", out); break;
case '"': fputs("&quot;", out); break;
case '\'':fputs("&apos;", out); break;
default: putc(c,out); break;
}
}
}

+ 42
- 0
discount-1.5.5/tests/autolink.t View File

@ -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

+ 53
- 0
discount-1.5.5/tests/automatic.t View File

@ -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>&lt;orc@></p>'
try 'invalid <@pell>' '<@pell>' '<p>&lt;@pell></p>'
try 'invalid <orc@pell>' '<orc@pell>' '<p>&lt;orc@pell></p>'
try 'invalid <orc@.pell>' '<orc@.pell>' '<p>&lt;orc@.pell></p>'
try 'invalid <orc@pell.>' '<orc@pell.>' '<p>&lt;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

+ 35
- 0
discount-1.5.5/tests/backslash.t View File

@ -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

discount-1.3.4/tests/chrome.text → discount-1.5.5/tests/chrome.text View File


+ 39
- 0
discount-1.5.5/tests/code.t View File

@ -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

+ 47
- 0
discount-1.5.5/tests/compat.t View File

@ -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

discount-1.3.4/tests/crash.t → discount-1.5.5/tests/crash.t View File

@ -36,4 +36,13 @@ else
rc=1
fi
./echo -n ' empty []() with baseurl .......... '
if ./markdown -bHOHO -s '[]()' >/dev/null 2>/dev/null; then
./echo "ok"
else
./echo "FAILED"
rc=1
fi
exit $rc

+ 67
- 0
discount-1.5.5/tests/div.t View File

@ -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

+ 69
- 0
discount-1.5.5/tests/dl.t View File

@ -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

discount-1.3.4/tests/embedlinks.text → discount-1.5.5/tests/embedlinks.text View File


+ 40
- 0
discount-1.5.5/tests/emphasis.t View File

@ -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

+ 52
- 0
discount-1.5.5/tests/flow.t View File

@ -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

+ 34
- 0
discount-1.5.5/tests/footnotes.t View File

@ -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

discount-1.3.4/tests/header.t → discount-1.5.5/tests/header.t View File

@ -4,20 +4,29 @@ rc=0
MARKDOWN_FLAGS=
try() {
unset FLAGS
case "$1" in
-*) FLAGS=$1
shift ;;
esac
S=`./echo -n "$1" '..................................' | cut -c 1-34`
S=`./echo -n "$1" '..................................' | ./cols 34`
./echo -n " $S "
count=`./echo "$2" | ./markdown | grep "$3" | wc -l`
Q=`./echo "$2" | ./markdown $FLAGS`
if [ $count -eq 1 ]; then
if [ "$3" = "$Q" ]; then
./echo "ok"
else
./echo "FAILED"
./echo "wanted: $3"
./echo "got : $Q"
rc=1
fi
}
try 'single #' '#' '<p>#</p>'
try 'empty ETX' '##' '<h1>#</h1>'
try 'single-char ETX (##W)' '##W' '<h2>W</h2>'
try 'single-char ETX (##W )' '##W ' '<h2>W</h2>'

+ 109
- 0
discount-1.5.5/tests/html.t View File

@ -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>&lt;b>hi!&lt;/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

discount-1.3.4/tests/links.text → discount-1.5.5/tests/links.text View File


+ 124
- 0
discount-1.5.5/tests/linkylinky.t View File

@ -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&amp;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&lt;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 <' \
'![he<he<he](url)' \
'<p><img src="url" alt="he&lt;he&lt;he" /></p>'
try 'image label contains >' \
'![he>he>he](url)' \
'<p><img src="url" alt="he&gt;he&gt;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

+ 31
- 0
discount-1.5.5/tests/linkypix.t View File

@ -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' \
'![picture](pic =200x200)' \
'<p><img src="pic" height="200" width="200" alt="picture" /></p>'
exit $rc

+ 168
- 0
discount-1.5.5/tests/list.t View File

@ -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

+ 57
- 0
discount-1.5.5/tests/list3deep.t View File

@ -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

+ 33
- 0
discount-1.5.5/tests/misc.t View File

@ -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 '< -> &lt;' '<' '<p>&lt;</p>'
try '`>` -> <code>&gt;</code>' '`>`' '<p><code>&gt;</code></p>'
try '`` ` `` -> <code>`</code>' '`` ` ``' '<p><code>`</code></p>'
exit $rc

+ 74
- 0
discount-1.5.5/tests/pandoc.t View File

@ -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

+ 38
- 0
discount-1.5.5/tests/para.t View File

@ -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

+ 31
- 0
discount-1.5.5/tests/paranoia.t View File

@ -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

+ 64
- 0
discount-1.5.5/tests/peculiarities.t View File

@ -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>&ndash; 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

+ 35
- 0
discount-1.5.5/tests/pseudo.t View File

@ -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

+ 34
- 0
discount-1.5.5/tests/reparse.t View File

@ -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

+ 97
- 0
discount-1.5.5/tests/schiraldi.t View File

@ -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&amp;b=c">http://foo.bar?a&amp;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&amp;b=c">http://foo.bar?a&amp;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;&amp;version=31;">http://www.biblegateway.com/passage/?search=Matthew%205:29-30;&amp;version=31;</a></p>'
exit $rc

+ 50
- 0
discount-1.5.5/tests/smarty.t View File

@ -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) -> &copy;' '(c)' '<p>&copy;</p>'
try '(r) -> &reg;' '(r)' '<p>&reg;</p>'
try '(tm) -> &trade;' '(tm)' '<p>&trade;</p>'
try '... -> &hellip;' '...' '<p>&hellip;</p>'
try '"--" -> &mdash;' '--' '<p>&mdash;</p>'
try '"-" -> &ndash;' 'regular -' '<p>regular &ndash;</p>'
try 'A-B -> A-B' 'A-B' '<p>A-B</p>'
try '"fancy" -> &ldquo;fancy&rdquo;' '"fancy"' '<p>&ldquo;fancy&rdquo;</p>'
try "'fancy'" "'fancy'" '<p>&lsquo;fancy&rsquo;</p>'
try "don<b>'t -> don<b>&rsquo;t" "don<b>'t" '<p>don<b>&rsquo;t</p>'
try "don't -> don&rsquo;t" "don't" '<p>don&rsquo;t</p>'
try "it's -> it&rsquo;s" "it's" '<p>it&rsquo;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

+ 34
- 0
discount-1.5.5/tests/snakepit.t View File

@ -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

discount-1.3.4/tests/style.t → discount-1.5.5/tests/style.t View File


discount-1.3.4/tests/syntax.text → discount-1.5.5/tests/syntax.text View File


+ 164
- 0
discount-1.5.5/tests/tables.t View File

@ -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
&ndash;|&ndash;
hello|sailor</p>'
exit $rc

+ 66
- 0
discount-1.5.5/tests/tabstop.t View File

@ -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

+ 41
- 0
discount-1.5.5/tests/toc.t View File

@ -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

+ 39
- 0
discount-1.5.5/tests/xml.t View File

@ -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' '&lt;p&gt;hello,sailor&lt;/p&gt;'
try -fcdata 'from mkd_generateline()' -t'"hello,sailor"' '&amp;ldquo;hello,sailor&amp;rdquo;'
try -fnocdata 'html output from markdown()' '"hello,sailor"' '<p>&ldquo;hello,sailor&rdquo;</p>'
try -fnocdata '... from mkd_generateline()' -t'"hello,sailor"' '&ldquo;hello,sailor&rdquo;'
try -fcdata 'xml output with multibyte utf-8' \
'tecnología y servicios más confiables' \
'&lt;p&gt;tecnología y servicios más confiables&lt;/p&gt;'
exit $rc

discount-1.3.4/theme.1 → discount-1.5.5/theme.1 View File


discount-1.3.4/theme.c → discount-1.5.5/theme.c View File

@ -310,7 +310,7 @@ ftitle(MMIOT *doc, FILE* output, int flags)
h = pagename;
if ( h )
mkd_text(h, strlen(h), output, flags);
mkd_generateline(h, strlen(h), output, flags);
}
@ -322,7 +322,7 @@ fdate(MMIOT *doc, FILE *output, int flags)
char *h = infop ? ctime(&infop->st_mtime) : mkd_doc_date(doc);
if ( h )
mkd_text(h, strlen(h), output, flags|MKD_TAGTEXT);
mkd_generateline(h, strlen(h), output, flags|MKD_TAGTEXT);
}
@ -339,7 +339,7 @@ fauthor(MMIOT *doc, FILE *output, int flags)
#endif
if ( h )
mkd_text(h, strlen(h), output, flags);
mkd_generateline(h, strlen(h), output, flags);
}
@ -373,7 +373,7 @@ ftoc(MMIOT *doc, FILE *output, int flags)
static void
fstyle(MMIOT *doc, FILE *output, int flags)
{
mkd_style(doc, output);
mkd_generatecss(doc, output);
}
@ -545,22 +545,16 @@ char **argv;
char *p, *q;
output = alloca(strlen(source) + strlen(".html") + 1);
if ( added_text ) {
strcpy(output, argv[0]);
strcat(output, ".html");
}
else {
strcpy(output, source);
strcpy(output, source);
if (( p = strchr(output, '/') ))
q = strrchr(p+1, '.');
else
q = strrchr(output, '.');
if (( p = strchr(output, '/') ))
q = strrchr(p+1, '.');
else
q = strrchr(output, '.');
if ( q )
*q = 0;
strcat(q, ".html");
}
if ( q )
*q = 0;
strcat(q, ".html");
}
}
if ( output ) {

discount-1.3.4/toc.c → discount-1.5.5/toc.c View File

@ -19,7 +19,7 @@
int
mkd_toc(Document *p, char **doc)
{
Paragraph *pp;
Paragraph *tp, *srcp;
int last_hnumber = 0;
Cstring res;
@ -31,27 +31,31 @@ mkd_toc(Document *p, char **doc)
if ( !(p && p->ctx) ) return -1;
if ( ! (p->ctx->flags & TOC) ) return 0;
for ( pp = p->code; pp ; pp = pp->next ) {
if ( pp->typ == HDR && pp->text ) {
for ( tp = p->code; tp ; tp = tp->next ) {
if ( tp->typ == SOURCE ) {
for ( srcp = tp->down; srcp; srcp = srcp->next ) {
if ( srcp->typ == HDR && srcp->text ) {
if ( last_hnumber == pp->hnumber )
Csprintf(&res, "%*s</li>\n", pp->hnumber, "");
else while ( last_hnumber > pp->hnumber ) {
Csprintf(&res, "%*s</li>\n%*s</ul>\n",
last_hnumber, "",
last_hnumber-1,"");
--last_hnumber;
}
while ( pp->hnumber > last_hnumber ) {
Csprintf(&res, "\n%*s<ul>\n", pp->hnumber, "");
++last_hnumber;
if ( last_hnumber == srcp->hnumber )
Csprintf(&res, "%*s</li>\n", srcp->hnumber, "");
else while ( last_hnumber > srcp->hnumber ) {
Csprintf(&res, "%*s</li>\n%*s</ul>\n",
last_hnumber, "",
last_hnumber-1,"");
--last_hnumber;
}
while ( srcp->hnumber > last_hnumber ) {
Csprintf(&res, "\n%*s<ul>\n", srcp->hnumber, "");
++last_hnumber;
}
Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
mkd_string_to_anchor(T(srcp->text->text), S(srcp->text->text), Csputc, &res);
Csprintf(&res, "\">");
Csreparse(&res, T(srcp->text->text), S(srcp->text->text), 0);
Csprintf(&res, "</a>");
}
}
Csprintf(&res, "%*s<li><a href=\"#", pp->hnumber, "");
mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Csputc, &res);
Csprintf(&res, "\">");
Csreparse(&res, T(pp->text->text), S(pp->text->text), 0);
Csprintf(&res, "</a>");
}
}

+ 38
- 0
discount-1.5.5/tools/cols.c View File

@ -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);
}

discount-1.3.4/echo.c → discount-1.5.5/tools/echo.c View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save