@Component(role=Parser.class, hint="markdown") public class MarkdownParser extends AbstractParser
Parser for Markdown documents.
Defers effective parsing to the PegDown library, which generates HTML content
then delegates parsing of this content to a slightly modified Doxia Xhtml parser.MarkdownToDoxiaHtmlSerializer| Modifier and Type | Class and Description |
|---|---|
static class |
MarkdownParser.PegDownHtmlParser
Internal parser for HTML generated by PegDown library.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
MULTI_MARKDOWN_METADATA_ENTRY
Regex that captures the key and value of a multimarkdown-style metadata entry.
|
private static java.lang.String |
MULTI_MARKDOWN_METADATA_SECTION
Regex that identifies a multimarkdown-style metadata section at the start of the document
|
private MarkdownParser.PegDownHtmlParser |
parser |
protected static org.pegdown.PegDownProcessor |
PEGDOWN_PROCESSOR
The
PegDownProcessor used to convert Pegdown documents to HTML. |
static java.lang.String |
ROLE_HINT
The role hint for the
MarkdownParser Plexus component. |
private static java.lang.String[] |
STANDARD_METADATA_KEYS
In order to ensure that we have minimal risk of false positives when slurping metadata sections, the
first key in the metadata section must be one of these standard keys or else the entire metadata section is
ignored.
|
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE| Constructor and Description |
|---|
MarkdownParser() |
| Modifier and Type | Method and Description |
|---|---|
int |
getType()
|
static boolean |
isHtmlComment(org.pegdown.ast.Node node) |
static java.lang.String |
nodeText(org.pegdown.ast.Node node) |
void |
parse(java.io.Reader source,
Sink sink)
Parses the given source model and emits Doxia events into the given sink.
|
private java.lang.String |
toHtml(java.io.Reader source)
uses PegDown library to parse content and generate HTML output.
|
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, init, isEmitComments, isSecondParsing, parse, parse, setEmitComments, setSecondParsingpublic static final java.lang.String ROLE_HINT
MarkdownParser Plexus component.protected static final org.pegdown.PegDownProcessor PEGDOWN_PROCESSOR
PegDownProcessor used to convert Pegdown documents to HTML.private static final java.lang.String MULTI_MARKDOWN_METADATA_SECTION
private static final java.lang.String MULTI_MARKDOWN_METADATA_ENTRY
private static final java.lang.String[] STANDARD_METADATA_KEYS
@Requirement private MarkdownParser.PegDownHtmlParser parser
public int getType()
AbstractParsergetType in interface ParsergetType in class AbstractParserpublic void parse(java.io.Reader source,
Sink sink)
throws ParseException
Parsersource - not null reader that provides the source document.
You could use newReader methods from ReaderFactory.sink - A sink that consumes the Doxia events.ParseException - if the model could not be parsed.private java.lang.String toHtml(java.io.Reader source)
throws java.io.IOException
source - the Markdown sourcejava.io.IOExceptionMarkdownToDoxiaHtmlSerializerpublic static boolean isHtmlComment(org.pegdown.ast.Node node)
public static java.lang.String nodeText(org.pegdown.ast.Node node)