Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A pure-Java Markdown processor based on a parboiled PEG parser - clean, lightweight, easy to extend.

branch: feature/visitor

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 src
Octocat-spinner-32 test-cases
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 LICENSE
Octocat-spinner-32 NOTICE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 build.xml
README.markdown

Introduction

pegdown is a pure Java library for clean and lightweight Markdown processing. It's implementation is based on a parboiled PEG parser and is therefore rather easy to understand and extend.

pegdown is nearly 100% compatible with the original Markdown specification and fully passes the original Markdown test suite. On top of the standard Markdown feature set pegdown implements a number of extensions similar to what other popular Markdown processors offer. Currently pegdown supports the following extensions over standard Markdown:

  • SMARTS: Beautifys apostrophes, ellipsises ("..." and ". . .") and dashes ("--" and "---")
  • QUOTES: Beautifys single quotes, double quotes and double angle quotes (« and »)
  • SMARTYPANTS: Convenience extension enabling both, SMARTS and QUOTES, at once.
  • ABBREVIATIONS: Support for abbreviations in the way of PHP Markdown Extra.
  • HARDWRAPS: Enables alternative handling of newlines, see Github-flavoured-Markdown
  • AUTOLINKS: Enables plain (undelimited) autolinks the way Github-flavoured-Markdown implements them.
  • TABLES: Enables support for tables similar to MultiMarkdown (which is in turn like the PHP Markdown Extra tables, but with colspan support).
  • HTML BLOCK SUPPRESSION: Suppresses the output of HTML blocks.
  • INLINE HTML SUPPRESSION: Suppresses the output of inline HTML elements.

Note: pegdown differs from the original Markdown in that it ignores in-word emphasis as in

> my_file.txt
> 2*3*4=5

Currently this "extension" cannot be switched off.

Installation

Download the JAR for latest version from the download page.
Additionally pegdown requires the parboiled JAR on the classpath (currently v0.9.9.0, upgrade to 0.10.0 pending).

Documentation

Using pegdown is very simple: Just create a new instance of a PegDownProcessor and call its markdownToHtml(String) method to convert the given Markdown source to an HTML string.

The first time you create a PegDownProcessor it can take up to a few hundred milliseconds to prepare the underlying parboiled parser instance, however, once the first processor has been built all further instantiations will be fast. Also, you can reuse an existing PegDownProcessor instance as often as you want, as long as you prevent concurrent accesses, since neither the PegDownProcessor nor the underlying parser is thread-safe.

See http://sirthias.github.com/pegdown/api for the pegdown API documation.

Credits

Most of the underlying PEG grammar was developed by John MacFarlane and made available with his tool peg-markdown.

Any feedback is, of course, very welcome.

Something went wrong with that request. Please try again.