org.pegdown
Class PegDownProcessor

java.lang.Object
  extended by org.pegdown.PegDownProcessor

public class PegDownProcessor
extends java.lang.Object

A clean and lightweight Markdown-to-HTML filter based on a PEG parser implemented with parboiled. Note: A PegDownProcessor is not thread-safe (since it internally reused the parboiled parser instance). If you need to process markdown source in parallel create one PegDownProcessor per thread!

See Also:
Markdown, parboiled.org

Field Summary
 Parser parser
           
 
Constructor Summary
PegDownProcessor()
          Creates a new processor instance without any enabled extensions.
PegDownProcessor(int options)
          Creates a new processor instance with the given Extensions.
PegDownProcessor(Parser parser)
          Creates a new processor instance using the given Parser and tabstop width.
 
Method Summary
 java.lang.String markdownToHtml(char[] markdownSource)
          Converts the given markdown source to HTML.
 java.lang.String markdownToHtml(char[] markdownSource, LinkRenderer linkRenderer)
          Converts the given markdown source to HTML.
 java.lang.String markdownToHtml(java.lang.String markdownSource)
          Converts the given markdown source to HTML.
 java.lang.String markdownToHtml(java.lang.String markdownSource, LinkRenderer linkRenderer)
          Converts the given markdown source to HTML.
 RootNode parseMarkdown(char[] markdownSource)
          Parses the given markdown source and returns the root node of the generated Abstract Syntax Tree.
 char[] prepareSource(char[] source)
          Adds two trailing newlines.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

public final Parser parser
Constructor Detail

PegDownProcessor

public PegDownProcessor()
Creates a new processor instance without any enabled extensions.


PegDownProcessor

public PegDownProcessor(int options)
Creates a new processor instance with the given Extensions.

Parameters:
options - the flags of the extensions to enable as a bitmask

PegDownProcessor

public PegDownProcessor(Parser parser)
Creates a new processor instance using the given Parser and tabstop width.

Parameters:
parser - the parser instance to use
Method Detail

markdownToHtml

public java.lang.String markdownToHtml(java.lang.String markdownSource)
Converts the given markdown source to HTML.

Parameters:
markdownSource - the markdown source to convert
Returns:
the HTML

markdownToHtml

public java.lang.String markdownToHtml(java.lang.String markdownSource,
                                       LinkRenderer linkRenderer)
Converts the given markdown source to HTML.

Parameters:
markdownSource - the markdown source to convert
linkRenderer - the LinkRenderer to use
Returns:
the HTML

markdownToHtml

public java.lang.String markdownToHtml(char[] markdownSource)
Converts the given markdown source to HTML.

Parameters:
markdownSource - the markdown source to convert
Returns:
the HTML

markdownToHtml

public java.lang.String markdownToHtml(char[] markdownSource,
                                       LinkRenderer linkRenderer)
Converts the given markdown source to HTML.

Parameters:
markdownSource - the markdown source to convert
linkRenderer - the LinkRenderer to use
Returns:
the HTML

parseMarkdown

public RootNode parseMarkdown(char[] markdownSource)
Parses the given markdown source and returns the root node of the generated Abstract Syntax Tree.

Parameters:
markdownSource - the markdown source to convert
Returns:
the AST root

prepareSource

public char[] prepareSource(char[] source)
Adds two trailing newlines.

Parameters:
source - the markdown source to process
Returns:
the processed source