Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
add package tests, comprising tests from the MarkdownTest_1.0.3 suite
Browse files Browse the repository at this point in the history
  • Loading branch information
knieriem committed May 4, 2012
1 parent 982e585 commit 7799c9c
Show file tree
Hide file tree
Showing 43 changed files with 3,588 additions and 34 deletions.
18 changes: 1 addition & 17 deletions Makefile
@@ -1,12 +1,5 @@
all:
@echo 'targets: test nuke parser clean'

#
# run MarkdownTests-1.0.3 that come with original C sources
#
test: package cmd orig-c-src
cd orig-c-src/MarkdownTest_1.0.3; \
./MarkdownTest.pl --script=../../cmd/markdown/markdown --tidy
@echo 'targets: nuke parser clean'

cmd: package
cd cmd/markdown && go build -v
Expand All @@ -16,7 +9,6 @@ package: parser.leg.go

clean:
go clean . ./...
rm -rf orig-c-src
rm -rf ,,prevmd ,,pmd

parser: parser.leg.go
Expand All @@ -35,13 +27,6 @@ include $(shell go list -f '{{.Dir}}' github.com/knieriem/peg)/Make.inc
endif


#
# get access to original C source files
#
orig-c-src:
hg clone git://github.com/jgm/peg-markdown.git $@


include misc/devel.mk

.PHONY: \
Expand All @@ -50,4 +35,3 @@ include misc/devel.mk
nuke\
package\
parser\
test\
25 changes: 10 additions & 15 deletions README.md
Expand Up @@ -11,7 +11,7 @@ by peg-markdown.
[Go]: http://golang.org/

Support for HTML output is implemented, but Groff and LaTeX
output have not been ported. The output should be identical
output have not been ported. The output is identical
to that of peg-markdown.

A simple benchmark has been done by comparing the
Expand Down Expand Up @@ -42,21 +42,16 @@ To create the command line program *markdown,* run

the binary should then be available in the current directory.

To run the Markdown 1.0.3 test suite, type
To run tests, type

make test
go test github.com/knieriem/markdown

This will download peg-markdown, in case you have Mercurial
and the hg-git extension available, build cmd/markdown, and
run the test suite.

The test suite should fail on exactly one test –
*Ordered and unordered lists* –, for the same reason which
applies to peg-markdown, because the grammar is the same.
See the [original README][] for details.

[original README]: https://github.com/jgm/peg-markdown/blob/master/README.markdown
At the moment, tests are based on the .text files from the
Markdown 1.0.3 test suite created by John Gruber, [imported from
peg-markdown][testsuite]. The output of the conversion of these
.text files to html is compared to the output of peg-markdown.

[testsuite]: https://github.com/jgm/peg-markdown/tree/master/MarkdownTest_1.0.3

## Development

Expand All @@ -66,8 +61,8 @@ when building packages and commands using the Go tool. To make
*markdown* installable using `go get`, `parser.leg.go` has
been added to the VCS.

`Make parser` will update `parser.leg.go` using `leg`, which
is part of [knieriem/peg][] at github, if parser.leg has
`Make parser` will update `parser.leg.go` using `leg` which
is part of [knieriem/peg][] at github, if parser.leg has
been changed, or if the Go file is missing. If a copy of *peg*
is not yet present on your system, run

Expand Down
4 changes: 2 additions & 2 deletions misc/devel.mk
Expand Up @@ -9,7 +9,7 @@ gofmt:
diff: ,,c
tkdiff $< parser.leg

,,c: orig-c-src/markdown_parser.leg
,,c: ,,pmd/markdown_parser.leg
sed -f misc/c2go.sed < $< > $@

orig-c-src/markdown_parser.leg: orig-c-src
Expand All @@ -18,7 +18,7 @@ orig-c-src/markdown_parser.leg: orig-c-src
bmprepare:
rc ./misc/bmprepare.rc

benchmark: m ,,pmd ,,prevmd
benchmark: cmd m ,,pmd ,,prevmd
rc ./misc/benchmark.rc


Expand Down
8 changes: 8 additions & 0 deletions tests/README.md
@@ -0,0 +1,8 @@
This directory contains test files used by ../markdown_test.go.

## INDEX

* *md1.0.3*

Files from John Gruber's test suite MarkdownTest_1.0.3,
imported from https://github.com/jgm/peg-markdown/.
6 changes: 6 additions & 0 deletions tests/gen.rc
@@ -0,0 +1,6 @@
pmd=../../,,pmd/markdown

for (i in *.text) {
stem=`{echo $i | sed 's,.text$,,'}
$pmd < $i >$"stem.html
}
17 changes: 17 additions & 0 deletions tests/md1.0.3/Amps and angle encoding.html
@@ -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 &gt; 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>
21 changes: 21 additions & 0 deletions tests/md1.0.3/Amps and angle encoding.text
@@ -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"
18 changes: 18 additions & 0 deletions tests/md1.0.3/Auto links.html
@@ -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>
13 changes: 13 additions & 0 deletions tests/md1.0.3/Auto links.text
@@ -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/>
117 changes: 117 additions & 0 deletions tests/md1.0.3/Backslash escapes.html
@@ -0,0 +1,117 @@
<p>These should all get escaped:</p>

<p>Backslash: \</p>

<p>Backtick: `</p>

<p>Asterisk: *</p>

<p>Underscore: _</p>

<p>Left brace: {</p>

<p>Right brace: }</p>

<p>Left bracket: [</p>

<p>Right bracket: ]</p>

<p>Left paren: (</p>

<p>Right paren: )</p>

<p>Greater-than: &gt;</p>

<p>Hash: #</p>

<p>Period: .</p>

<p>Bang: !</p>

<p>Plus: +</p>

<p>Minus: -</p>

<p>These should not, because they occur within a code block:</p>

<pre><code>Backslash: \\

Backtick: \`

Asterisk: \*

Underscore: \_

Left brace: \{

Right brace: \}

Left bracket: \[

Right bracket: \]

Left paren: \(

Right paren: \)

Greater-than: \&gt;

Hash: \#

Period: \.

Bang: \!

Plus: \+

Minus: \-
</code></pre>

<p>Nor should these, which occur in code spans:</p>

<p>Backslash: <code>\\</code></p>

<p>Backtick: <code>\`</code></p>

<p>Asterisk: <code>\*</code></p>

<p>Underscore: <code>\_</code></p>

<p>Left brace: <code>\{</code></p>

<p>Right brace: <code>\}</code></p>

<p>Left bracket: <code>\[</code></p>

<p>Right bracket: <code>\]</code></p>

<p>Left paren: <code>\(</code></p>

<p>Right paren: <code>\)</code></p>

<p>Greater-than: <code>\&gt;</code></p>

<p>Hash: <code>\#</code></p>

<p>Period: <code>\.</code></p>

<p>Bang: <code>\!</code></p>

<p>Plus: <code>\+</code></p>

<p>Minus: <code>\-</code></p>

<p>These should get escaped, even though they're matching pairs for
other Markdown constructs:</p>

<p>*asterisks*</p>

<p>_underscores_</p>

<p>`backticks`</p>

<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>

<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>

<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>

0 comments on commit 7799c9c

Please sign in to comment.