2010-12-01 21:29:50 +00: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
|
2012-05-04 14:36:04 +00:00
|
|
|
|
LEG grammars --, which itself is based on the parser used
|
2010-12-01 21:29:50 +00:00
|
|
|
|
by peg-markdown.
|
|
|
|
|
|
|
|
|
|
[markdown]: http://daringfireball.net/projects/markdown/
|
|
|
|
|
[peg-markdown]: https://github.com/jgm/peg-markdown
|
|
|
|
|
[peg]: https://github.com/pointlander/peg
|
|
|
|
|
[Go]: http://golang.org/
|
|
|
|
|
|
2012-08-31 22:29:18 +00:00
|
|
|
|
Support for HTML and groff mm output is implemented, but LaTeX
|
|
|
|
|
output has not been ported. The output is identical
|
2010-12-01 21:29:50 +00:00
|
|
|
|
to that of peg-markdown.
|
|
|
|
|
|
2012-05-04 14:36:04 +00:00
|
|
|
|
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].*
|
|
|
|
|
|
2013-04-29 18:38:33 +00:00
|
|
|
|
The Markdown parser has a performance similar to that of
|
|
|
|
|
the original C version, and consumes less memory.
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
Provided you have a copy of Go 1, and git is available,
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
go get github.com/knieriem/markdown
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
should download and install the package according to
|
|
|
|
|
your GOPATH settings.
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2013-04-29 18:38:33 +00:00
|
|
|
|
See doc.go for an example how to use the package.
|
2012-05-04 14:36:04 +00:00
|
|
|
|
|
|
|
|
|
---
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
|
|
|
|
To create the command line program *markdown,* run
|
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
go build github.com/knieriem/markdown/cmd/markdown
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
the binary should then be available in the current directory.
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-05-04 10:42:16 +00:00
|
|
|
|
To run tests, type
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-05-04 10:42:16 +00:00
|
|
|
|
go test github.com/knieriem/markdown
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-05-04 10:42:16 +00:00
|
|
|
|
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.
|
2010-12-13 18:44:11 +00:00
|
|
|
|
|
2012-05-04 10:42:16 +00:00
|
|
|
|
[testsuite]: https://github.com/jgm/peg-markdown/tree/master/MarkdownTest_1.0.3
|
2012-04-20 23:44:22 +00:00
|
|
|
|
|
2010-12-13 18:44:11 +00:00
|
|
|
|
## Development
|
|
|
|
|
|
2012-04-20 23:44:22 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2012-05-04 10:42:16 +00:00
|
|
|
|
`Make parser` will update `parser.leg.go` using `leg` – which
|
|
|
|
|
is part of [knieriem/peg][] at github –, if parser.leg has
|
2012-04-20 23:44:22 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2010-12-01 21:29:50 +00:00
|
|
|
|
[knieriem/peg]: https://github.com/knieriem/peg
|
|
|
|
|
|
2010-12-13 18:36:35 +00:00
|
|
|
|
|
|
|
|
|
## 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][].
|
|
|
|
|
|
2010-12-13 18:44:11 +00:00
|
|
|
|
Definitions (`<dd>...</dd>`) are implemented using [`ListTight`][ListTight]
|
2010-12-13 18:36:35 +00:00
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
[PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/#def-list
|
|
|
|
|
[ListTight]: https://github.com/knieriem/markdown/blob/master/parser.leg#L191
|
|
|
|
|
|
|
|
|
|
|
2010-12-01 21:29:50 +00:00
|
|
|
|
## Todo
|
|
|
|
|
|
2012-05-04 14:36:04 +00:00
|
|
|
|
* Port tables and perhaps other extensions from [fletcher/peg-multimarkdown][mmd].
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
|
|
|
|
## Subdirectory Index
|
|
|
|
|
|
2012-04-29 22:56:41 +00:00
|
|
|
|
* cmd/markdown – command line program `markdown`
|
2010-12-01 21:29:50 +00:00
|
|
|
|
|
2012-05-04 14:36:04 +00:00
|
|
|
|
[mmd]: https://github.com/fletcher/peg-multimarkdown
|