Permalink
Browse files

Initial commit.

  • Loading branch information...
jgm committed May 2, 2008
0 parents commit d686afba0380d2887259f3b622e32297dcb0354b
Showing with 12,505 additions and 0 deletions.
  1. +64 −0 LICENSE
  2. +30 −0 Makefile
  3. +176 −0 MarkdownTest_1.0.3/MarkdownTest.pl
  4. +17 −0 MarkdownTest_1.0.3/Tests/Amps and angle encoding.html
  5. +21 −0 MarkdownTest_1.0.3/Tests/Amps and angle encoding.text
  6. +18 −0 MarkdownTest_1.0.3/Tests/Auto links.html
  7. +13 −0 MarkdownTest_1.0.3/Tests/Auto links.text
  8. +118 −0 MarkdownTest_1.0.3/Tests/Backslash escapes.html
  9. +120 −0 MarkdownTest_1.0.3/Tests/Backslash escapes.text
  10. +15 −0 MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html
  11. +11 −0 MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text
  12. +18 −0 MarkdownTest_1.0.3/Tests/Code Blocks.html
  13. +14 −0 MarkdownTest_1.0.3/Tests/Code Blocks.text
  14. +6 −0 MarkdownTest_1.0.3/Tests/Code Spans.html
  15. +6 −0 MarkdownTest_1.0.3/Tests/Code Spans.text
  16. +8 −0 MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html
  17. +8 −0 MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text
  18. +71 −0 MarkdownTest_1.0.3/Tests/Horizontal rules.html
  19. +67 −0 MarkdownTest_1.0.3/Tests/Horizontal rules.text
  20. +15 −0 MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html
  21. +15 −0 MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text
  22. +72 −0 MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html
  23. +69 −0 MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text
  24. +13 −0 MarkdownTest_1.0.3/Tests/Inline HTML comments.html
  25. +13 −0 MarkdownTest_1.0.3/Tests/Inline HTML comments.text
  26. +11 −0 MarkdownTest_1.0.3/Tests/Links, inline style.html
  27. +12 −0 MarkdownTest_1.0.3/Tests/Links, inline style.text
  28. +52 −0 MarkdownTest_1.0.3/Tests/Links, reference style.html
  29. +71 −0 MarkdownTest_1.0.3/Tests/Links, reference style.text
  30. +9 −0 MarkdownTest_1.0.3/Tests/Links, shortcut references.html
  31. +20 −0 MarkdownTest_1.0.3/Tests/Links, shortcut references.text
  32. +3 −0 MarkdownTest_1.0.3/Tests/Literal quotes in titles.html
  33. +7 −0 MarkdownTest_1.0.3/Tests/Literal quotes in titles.text
  34. +314 −0 MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html
  35. +306 −0 MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text
  36. +942 −0 MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html
  37. +888 −0 MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text
  38. +9 −0 MarkdownTest_1.0.3/Tests/Nested blockquotes.html
  39. +5 −0 MarkdownTest_1.0.3/Tests/Nested blockquotes.text
  40. +148 −0 MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html
  41. +131 −0 MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text
  42. +7 −0 MarkdownTest_1.0.3/Tests/Strong and em together.html
  43. +7 −0 MarkdownTest_1.0.3/Tests/Strong and em together.text
  44. +25 −0 MarkdownTest_1.0.3/Tests/Tabs.html
  45. +21 −0 MarkdownTest_1.0.3/Tests/Tabs.text
  46. +8 −0 MarkdownTest_1.0.3/Tests/Tidyness.html
  47. +5 −0 MarkdownTest_1.0.3/Tests/Tidyness.text
  48. +70 −0 README
  49. +1,422 −0 markdown.leg
  50. +22 −0 my_getopt-1.5/ChangeLog
  51. +22 −0 my_getopt-1.5/LICENSE
  52. +26 −0 my_getopt-1.5/Makefile
  53. +140 −0 my_getopt-1.5/README
  54. +288 −0 my_getopt-1.5/getopt.3
  55. +56 −0 my_getopt-1.5/getopt.h
  56. +330 −0 my_getopt-1.5/getopt.txt
  57. +387 −0 my_getopt-1.5/main.c
  58. +281 −0 my_getopt-1.5/my_getopt.c
  59. +72 −0 my_getopt-1.5/my_getopt.h
  60. +58 −0 peg-0.1.4/Makefile
  61. +676 −0 peg-0.1.4/compile.c
  62. +79 −0 peg-0.1.4/examples/Makefile
  63. +11 −0 peg-0.1.4/examples/accept.c
  64. +8 −0 peg-0.1.4/examples/accept.peg
  65. +32 −0 peg-0.1.4/examples/accept.ref
  66. +360 −0 peg-0.1.4/examples/basic.leg
  67. +10 −0 peg-0.1.4/examples/basic.ref
  68. +8 −0 peg-0.1.4/examples/bench.bas
  69. +46 −0 peg-0.1.4/examples/calc.leg
  70. +3 −0 peg-0.1.4/examples/calc.ref
  71. +17 −0 peg-0.1.4/examples/dc.c
  72. +27 −0 peg-0.1.4/examples/dc.peg
  73. +1 −0 peg-0.1.4/examples/dc.ref
  74. +20 −0 peg-0.1.4/examples/dcv.c
  75. +34 −0 peg-0.1.4/examples/dcv.peg
  76. +3 −0 peg-0.1.4/examples/dcv.ref
  77. +17 −0 peg-0.1.4/examples/fibonacci.bas
  78. +17 −0 peg-0.1.4/examples/left.c
  79. +3 −0 peg-0.1.4/examples/left.peg
  80. +11 −0 peg-0.1.4/examples/rule.c
  81. +8 −0 peg-0.1.4/examples/rule.peg
  82. +32 −0 peg-0.1.4/examples/rule.ref
  83. +12 −0 peg-0.1.4/examples/test.bas
  84. +8 −0 peg-0.1.4/examples/test.c
  85. +13 −0 peg-0.1.4/examples/test.peg
  86. +10 −0 peg-0.1.4/examples/test.ref
  87. +14 −0 peg-0.1.4/examples/username.leg
  88. +22 −0 peg-0.1.4/examples/wc.leg
  89. +55 −0 peg-0.1.4/examples/wc.ref
  90. +1,083 −0 peg-0.1.4/leg.c
  91. +292 −0 peg-0.1.4/leg.leg
  92. +887 −0 peg-0.1.4/peg.1
  93. +173 −0 peg-0.1.4/peg.c
  94. +77 −0 peg-0.1.4/peg.peg
  95. +800 −0 peg-0.1.4/peg.peg-c
  96. +352 −0 peg-0.1.4/tree.c
  97. +108 −0 peg-0.1.4/tree.h
  98. +3 −0 peg-0.1.4/version.h
64 LICENSE
@@ -0,0 +1,64 @@
+markdown in c, implemented using PEG grammar
+Copyright (c) 2008 John MacFarlane
+
+Released under GPL:
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+
+peg-0.1.4 (included for convenience - http://piumarta.com/software/peg/)
+
+Copyright (c) 2007 by Ian Piumarta
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the 'Software'),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, provided that the above copyright notice(s) and this
+permission notice appear in all copies of the Software. Acknowledgement
+of the use of this Software in supporting documentation would be
+appreciated but is not required.
+
+THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK.
+
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+
+my_getopt (included for convenience - http://www.geocities.com/bsittler/)
+
+Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
@@ -0,0 +1,30 @@
+ALL : markdown
+
+PROGRAM=markdown
+MYGETOPTDIR=my_getopt-1.5
+OBJS=$(MYGETOPTDIR)/my_getopt.o
+PEGDIR=peg-0.1.4
+LEG=$(PEGDIR)/leg
+
+$(LEG):
+ make -C $(PEGDIR)
+
+%.o : %.c
+ $(CC) -c -o $@ $<
+
+markdown : markdown.c $(OBJS)
+ $(CC) -Wall -O3 -ansi -o $@ $(OBJS) $<
+
+markdown.c : markdown.leg $(LEG)
+ $(LEG) -o $@ $<
+
+.PHONY: clean test
+
+clean:
+ rm markdown.c $(PROGRAM) $(OBJS); \
+ make -C $(PEGDIR) spotless
+
+test: $(PROGRAM)
+ cd MarkdownTest_1.0.3; \
+ ./MarkdownTest.pl --script=../$(PROGRAM) --tidy
+
@@ -0,0 +1,176 @@
+#!/usr/bin/perl
+
+#
+# MarkdownTester -- Run tests for Markdown implementations
+#
+# Copyright (c) 2004-2005 John Gruber
+# <http://daringfireball.net/projects/markdown/>
+#
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Benchmark;
+
+our $VERSION = '1.0.2';
+# Sat 24 Dec 2005
+
+my $time_start = new Benchmark;
+my $test_dir = "Tests";
+my $script = "./Markdown.pl";
+my $use_tidy = 0;
+my ($flag_version);
+
+GetOptions (
+ "script=s" => \$script,
+ "testdir=s" => \$test_dir,
+ "tidy" => \$use_tidy,
+ "version" => \$flag_version,
+ );
+
+if($flag_version) {
+ my $progname = $0;
+ $progname =~ s{.*/}{};
+ die "$progname version $VERSION\n";
+}
+
+unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; }
+unless (-f $script) { die "$script does not exist.\n"; }
+unless (-x $script) { die "$script is not executable.\n"; }
+
+my $tests_passed = 0;
+my $tests_failed = 0;
+
+TEST:
+foreach my $testfile (glob "$test_dir/*.text") {
+ my $testname = $testfile;
+ $testname =~ s{.*/(.+)\.text$}{$1}i;
+ print "$testname ... ";
+
+ # Look for a corresponding .html file for each .text file:
+ my $resultfile = $testfile;
+ $resultfile =~ s{\.text$}{\.html}i;
+ unless (-f $resultfile) {
+ print "'$resultfile' does not exist.\n\n";
+ next TEST;
+ }
+
+ # open(TEST, $testfile) || die("Can't open testfile: $!");
+ open(RESULT, $resultfile) || die("Can't open resultfile: $!");
+ undef $/;
+ # my $t_input = <TEST>;
+ my $t_result = <RESULT>;
+
+ my $t_output = `'$script' '$testfile'`;
+
+ # Normalize the output and expected result strings:
+ $t_result =~ s/\s+\z//; # trim trailing whitespace
+ $t_output =~ s/\s+\z//; # trim trailing whitespace
+ if ($use_tidy) {
+ # Escape the strings, pass them through to CLI tidy tool for tag-level equivalency
+ $t_result =~ s{'}{'\\''}g; # escape ' chars for shell
+ $t_output =~ s{'}{'\\''}g;
+ $t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
+ $t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
+ }
+
+ if ($t_output eq $t_result) {
+ print "OK\n";
+ $tests_passed++;
+ }
+ else {
+ print "FAILED\n\n";
+# This part added by JM to print diffs
+ open(OUT, '>tmp1') or die $!;
+ print OUT $t_output or die $!;
+ open(RES, '>tmp2') or die $!;
+ print RES $t_result or die $!;
+ print `diff tmp1 tmp2`;
+ close RES;
+ close OUT;
+ print "\n";
+ `rm tmp?`;
+# End of added part
+ $tests_failed++;
+ }
+}
+
+print "\n\n";
+print "$tests_passed passed; $tests_failed failed.\n";
+
+my $time_end = new Benchmark;
+my $time_diff = timediff($time_end, $time_start);
+print "Benchmark: ", timestr($time_diff), "\n";
+
+
+__END__
+
+=pod
+
+=head1 NAME
+
+B<MarkdownTest>
+
+
+=head1 SYNOPSIS
+
+B<MarkdownTest.pl> [ B<--options> ] [ I<file> ... ]
+
+
+=head1 DESCRIPTION
+
+
+=head1 OPTIONS
+
+Use "--" to end switch parsing. For example, to open a file named "-z", use:
+
+ MarkdownTest.pl -- -z
+
+=over 4
+
+=item B<--script>
+
+Specify the path to the Markdown script to test. Defaults to
+"./Markdown.pl". Example:
+
+ ./MarkdownTest.pl --script ./PHP-Markdown/php-markdown
+
+=item B<--testdir>
+
+Specify the path to a directory containing test data. Defaults to "Tests".
+
+=item B<--tidy>
+
+Flag to turn on using the command line 'tidy' tool to normalize HTML
+output before comparing script output to the expected test result.
+Assumes that the 'tidy' command is available in your PATH. Defaults to
+off.
+
+=back
+
+
+
+=head1 BUGS
+
+
+
+=head1 VERSION HISTORY
+
+1.0 Mon 13 Dec 2004-2005
+
+1.0.1 Mon 19 Sep 2005
+
+ + Better handling of case when foo.text exists, but foo.html doesn't.
+ It now prints a message and moves on, rather than dying.
+
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2004-2005 John Gruber
+<http://daringfireball.net/>
+All rights reserved.
+
+This is free software; you may redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
@@ -0,0 +1,17 @@
+<p>AT&amp;T has an ampersand in their name.</p>
+
+<p>AT&amp;T is another way to write it.</p>
+
+<p>This &amp; that.</p>
+
+<p>4 &lt; 5.</p>
+
+<p>6 > 5.</p>
+
+<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
+
+<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
+
+<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
+
+<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
@@ -0,0 +1,21 @@
+AT&T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Here's a [link] [1] with an ampersand in the URL.
+
+Here's a link with an amersand in the link text: [AT&T] [2].
+
+Here's an inline [link](/script?foo=1&bar=2).
+
+Here's an inline [link](</script?foo=1&bar=2>).
+
+
+[1]: http://example.com/?foo=1&bar=2
+[2]: http://att.com/ "AT&T"
@@ -0,0 +1,18 @@
+<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
+
+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
+
+<ul>
+<li>In a list?</li>
+<li><a href="http://example.com/">http://example.com/</a></li>
+<li>It should.</li>
+</ul>
+
+<blockquote>
+ <p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
+</blockquote>
+
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+
+<pre><code>or here: &lt;http://example.com/&gt;
+</code></pre>
@@ -0,0 +1,13 @@
+Link: <http://example.com/>.
+
+With an ampersand: <http://example.com/?foo=1&bar=2>
+
+* In a list?
+* <http://example.com/>
+* It should.
+
+> Blockquoted: <http://example.com/>
+
+Auto-links should not occur here: `<http://example.com/>`
+
+ or here: <http://example.com/>
Oops, something went wrong.

0 comments on commit d686afb

Please sign in to comment.