Go to file
2013-06-12 14:20:19 +02:00
cmd/markdown disable strike-through extension by default [jgm/peg-markdown] 2013-06-11 02:00:44 +02:00
misc misc/c2go.sed: update 2012-05-04 16:36:55 +02:00
tests Add strike-through support for groff output [jgm/peg-markdown] 2013-06-11 02:45:09 +02:00
.hgignore initial import 2010-11-21 23:04:39 +01:00
.hgtags add tags go.r58 and go.r59 2011-12-03 00:47:57 +01:00
doc.go rename: Options -> Extensions 2012-05-04 16:20:29 +02:00
elemheap.go mk_element: turn global allocation into a per-parser, reusable allocation. 2012-04-29 23:54:10 +02:00
LICENSE initial import 2010-11-21 23:04:39 +01:00
Makefile add package tests, comprising tests from the MarkdownTest_1.0.3 suite 2012-05-04 12:42:16 +02:00
markdown_test.go gofmt 2013-01-23 21:51:00 +01:00
markdown.go Parser: add MarkdownString 2013-06-12 14:20:19 +02:00
out-groffmm.go Add strike-through support for groff output [jgm/peg-markdown] 2013-06-11 02:45:09 +02:00
output.go New extension: strike through with two tildes [jgm/peg-markdown] 2013-06-11 01:51:23 +02:00
parser.leg update parser interface 2013-06-12 14:17:16 +02:00
parser.leg.go parser.leg.go: update 2013-06-12 14:17:30 +02:00
portid Sp? is redundant… [jgm/peg-markdown] 2013-06-11 02:53:42 +02:00
README.md README: cleanup 2013-04-29 20:38:33 +02:00

This is an implementation of John Gruber's markdown in Go. It is a translation of peg-markdown, written by John MacFarlane in C, into Go. It is using a modified version of Andrew J Snodgrass' PEG parser peg -- now supporting LEG grammars --, which itself is based on the parser used by peg-markdown.

Support for HTML and groff mm output is implemented, but LaTeX output has not been ported. The output is identical to that of peg-markdown.

I try to keep the grammar in sync with the C version, by cherry-picking relevant changes. In the commit history the corresponding revisions have a suffix [jgm/peg-markdown].

The Markdown parser has a performance similar to that of the original C version, and consumes less memory.

Installation

Provided you have a copy of Go 1, and git is available,

go get github.com/knieriem/markdown

should download and install the package according to your GOPATH settings.

See doc.go for an example how to use the package.


To create the command line program markdown, run

go build github.com/knieriem/markdown/cmd/markdown

the binary should then be available in the current directory.

To run tests, type

go test github.com/knieriem/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. The output of the conversion of these .text files to html is compared to the output of peg-markdown.

Development

There is not yet a way to create a Go source file like parser.leg.go automatically from another file, parser.leg, 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 been changed, or if the Go file is missing. If a copy of peg is not yet present on your system, run

go get github.com/knieriem/peg

Then make parser should succeed.

Extensions

In addition to the extensions already present in peg-markdown, this package also supports definition lists (option -dlists) similar to the way they are described in the documentation of PHP Markdown Extra.

Definitions (<dd>...</dd>) are implemented using ListTight and ListLoose, on which bullet lists and ordered lists are based already. If there is an empty line between the definition title and the first definition, a loose list is expected, a tight list otherwise.

As definition item markers both : and ~ can be used.

Todo

Subdirectory Index

  • cmd/markdown command line program markdown