GithubHelp home page GithubHelp logo

newblue / markdown Goto Github PK

View Code? Open in Web Editor NEW

This project forked from knieriem/markdown

1.0 2.0 0.0 321 KB

A translation of peg-markdown (an implementation of Markdown in C, using a PEG grammar) into Go (http://golang.org/)

License: Other

markdown's Introduction

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 is itself based on the parser used by peg-markdown.

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

A simple benchmark has been done by comparing the execution time of the Go binary (cmd/main.go) and the original C implementation's binary needed for processing a Markdown document, which had been created by concatenating ten Markdown syntax descriptions.

In December 2010, the 8g compiled Go version still was around 3.5 times slower than the original C version.

In the meantime Go compilers and runtime have been improved, which reduced the factor down to around 2.5 for both 8g and 6g for the unmodified sources.

After some current changes to the peg/leg parser generator the Markdown parser can take advantage of the switch optimization now. This further reduced the execution time difference to 1.9x for 6/8g.

Installation

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

goinstall github.com/knieriem/markdown

should install the package into $GOROOT/src/pkg/github.com/knieriem/markdown, and build it.

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

To create the command line program markdown, run

cd $GOROOT/src/pkg/github.com/knieriem/markdown
gomake cmd

the binary should then be available in subdirectory cmd.

To run the Markdown 1.0.3 test suite, type

make mdtest

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

The test suite will fail on one test, for the same reason which applies to peg-markdown, because the grammar is the same. See the original README for details.

Development

Goinstall is creating its own Makefiles to build packages, based on the .go files found in the directory. It would not know about parser.leg.go, which had to be built by leg from the parser.leg grammar source file first. Because of this, to make markdown installable using goinstall, parser.leg.go has been added to the VCS.

Make will update parser.leg.go using leg, which is part of knieriem/peg at github, if parser.leg has been changed. If a copy of this package has not yet been downloaded -- i.e. no directory ./peg is present --, make will perform the neccessary steps automatically (run make peg to manually download knieriem/peg).

To update knieriem/peg run gomake update-peg. This will fetch available revisions from github, and remove the old leg binary.

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

  • Implement tables

  • Rename element key identifiers, so that they are not public

  • Where appropriate, use more idiomatic Go code

Subdirectory Index

  • peg – PEG parser generator (modified) from Andrew J Snodgrass

  • peg/leg – LEG parser generator, based on PEG

  • cmd – command line program markdown

markdown's People

Contributors

knieriem avatar

Stargazers

newblue avatar

Watchers

newblue avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.