Class MarkdownParser
java.lang.Object
org.apache.maven.doxia.parser.AbstractParser
org.apache.maven.doxia.parser.AbstractTextParser
org.apache.maven.doxia.module.markdown.MarkdownParser
- All Implemented Interfaces:
LogEnabled
,Markup
,TextMarkup
,Parser
@Component(role=Parser.class,
hint="markdown")
public class MarkdownParser
extends AbstractTextParser
implements TextMarkup
Implementation of Parser
for Markdown documents.
Defers effective parsing to the flexmark-java library, which generates HTML content then delegates parsing of this content to a slightly modified Doxia Xhtml parser. (before 1.8, the PegDown library was used)
- Since:
- 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Internal parser for HTML generated by the Markdown library. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final com.vladsch.flexmark.html.HtmlRenderer
Flexmark's HTML renderer (its output will be re-parsed and converted to Sink events)private static final com.vladsch.flexmark.parser.Parser
Flexmark's Markdown parser (one static instance fits all)private static final Pattern
Regex that captures the key and value of a multimarkdown-style metadata entry.private static final Pattern
Regex that identifies a multimarkdown-style metadata section at the start of the document 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.The parser of the HTML produced by Flexmark, that we will use to convert this HTML to Sink eventsstatic final String
The role hint for theMarkdownParser
Plexus component.Fields inherited from interface org.apache.maven.doxia.markup.Markup
COLON, EOL, EQUAL, GREATER_THAN, LEFT_CURLY_BRACKET, LEFT_SQUARE_BRACKET, LESS_THAN, MINUS, PLUS, QUOTE, RIGHT_CURLY_BRACKET, RIGHT_SQUARE_BRACKET, SEMICOLON, SLASH, SPACE, STAR
Fields inherited from interface org.apache.maven.doxia.parser.Parser
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE
Fields inherited from interface org.apache.maven.doxia.markup.TextMarkup
PIPE
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.maven.doxia.parser.AbstractTextParser
getType
Methods inherited from class org.apache.maven.doxia.parser.AbstractParser
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, init, isEmitComments, isSecondParsing, parse, parse, parse, setEmitComments, setSecondParsing
-
Field Details
-
ROLE_HINT
The role hint for theMarkdownParser
Plexus component.- See Also:
-
METADATA_SECTION_PATTERN
Regex that identifies a multimarkdown-style metadata section at the start of the document 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. -
METADATA_ENTRY_PATTERN
Regex that captures the key and value of a multimarkdown-style metadata entry. -
parser
The parser of the HTML produced by Flexmark, that we will use to convert this HTML to Sink events -
FLEXMARK_PARSER
private static final com.vladsch.flexmark.parser.Parser FLEXMARK_PARSERFlexmark's Markdown parser (one static instance fits all) -
FLEXMARK_HTML_RENDERER
private static final com.vladsch.flexmark.html.HtmlRenderer FLEXMARK_HTML_RENDERERFlexmark's HTML renderer (its output will be re-parsed and converted to Sink events)
-
-
Constructor Details
-
MarkdownParser
public MarkdownParser()
-
-
Method Details
-
parse
Parses the given source model and emits Doxia events into the given sink.- Specified by:
parse
in interfaceParser
- Parameters:
source
- not null reader that provides the source document. You could usenewReader
methods fromReaderFactory
.sink
- A sink that consumes the Doxia events.reference
- the reference- Throws:
ParseException
- if the model could not be parsed.
-
toHtml
uses flexmark-java library to parse content and generate HTML output.- Parameters:
source
- the Markdown source- Returns:
- HTML content generated by flexmark-java
- Throws:
IOException
- passed through
-