Package org.pegdown
Class PegDownProcessor
java.lang.Object
org.pegdown.PegDownProcessor
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new processor instance without any enabled extensions and the default parsing timeout.PegDownProcessor
(int options) Creates a new processor instance with the givenExtensions
and the default parsing timeout.PegDownProcessor
(int options, long maxParsingTimeInMillis) Creates a new processor instance with the givenExtensions
and parsing timeout.PegDownProcessor
(int options, long maxParsingTimeInMillis, PegDownPlugins plugins) Creates a new processor instance with the givenExtensions
, parsing timeout and plugins.PegDownProcessor
(int options, PegDownPlugins plugins) Creates a new processor instance with the givenExtensions
and plugins.PegDownProcessor
(long maxParsingTimeInMillis) Creates a new processor instance without any enabled extensions and the given parsing timeout.PegDownProcessor
(Parser parser) Creates a new processor instance using the given Parser. -
Method Summary
Modifier and TypeMethodDescriptionmarkdownToHtml
(char[] markdownSource) Converts the given markdown source to HTML.markdownToHtml
(char[] markdownSource, LinkRenderer linkRenderer) Converts the given markdown source to HTML.markdownToHtml
(char[] markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) markdownToHtml
(String markdownSource) Converts the given markdown source to HTML.markdownToHtml
(String markdownSource, LinkRenderer linkRenderer) Converts the given markdown source to HTML.markdownToHtml
(String markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) 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.
-
Field Details
-
DEFAULT_MAX_PARSING_TIME
public static final long DEFAULT_MAX_PARSING_TIME- See Also:
-
parser
-
-
Constructor Details
-
PegDownProcessor
public PegDownProcessor()Creates a new processor instance without any enabled extensions and the default parsing timeout. -
PegDownProcessor
public PegDownProcessor(long maxParsingTimeInMillis) Creates a new processor instance without any enabled extensions and the given parsing timeout. -
PegDownProcessor
public PegDownProcessor(int options) Creates a new processor instance with the givenExtensions
and the default parsing timeout.- Parameters:
options
- the flags of the extensions to enable as a bitmask
-
PegDownProcessor
public PegDownProcessor(int options, long maxParsingTimeInMillis) Creates a new processor instance with the givenExtensions
and parsing timeout.- Parameters:
options
- the flags of the extensions to enable as a bitmaskmaxParsingTimeInMillis
- the parsing timeout
-
PegDownProcessor
Creates a new processor instance with the givenExtensions
and plugins.- Parameters:
options
- the flags of the extensions to enable as a bitmaskplugins
- the plugins to use
-
PegDownProcessor
Creates a new processor instance with the givenExtensions
, parsing timeout and plugins.- Parameters:
options
- the flags of the extensions to enable as a bitmaskmaxParsingTimeInMillis
- the parsing timeoutplugins
- the plugins to use
-
PegDownProcessor
Creates a new processor instance using the given Parser.- Parameters:
parser
- the parser instance to use
-
-
Method Details
-
markdownToHtml
Converts the given markdown source to HTML. If the input cannot be parsed within the configured parsing timeout the method returns null.- Parameters:
markdownSource
- the markdown source to convert- Returns:
- the HTML
-
markdownToHtml
Converts the given markdown source to HTML. If the input cannot be parsed within the configured parsing timeout the method returns null.- Parameters:
markdownSource
- the markdown source to convertlinkRenderer
- the LinkRenderer to use- Returns:
- the HTML
-
markdownToHtml
public String markdownToHtml(String markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) -
markdownToHtml
Converts the given markdown source to HTML. If the input cannot be parsed within the configured parsing timeout the method returns null.- Parameters:
markdownSource
- the markdown source to convert- Returns:
- the HTML
-
markdownToHtml
Converts the given markdown source to HTML. If the input cannot be parsed within the configured parsing timeout the method returns null.- Parameters:
markdownSource
- the markdown source to convertlinkRenderer
- the LinkRenderer to use- Returns:
- the HTML
-
markdownToHtml
public String markdownToHtml(char[] markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) -
parseMarkdown
Parses the given markdown source and returns the root node of the generated Abstract Syntax Tree. If the input cannot be parsed within the configured parsing timeout the method throws a ParsingTimeoutException.- 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
-