InlineParser constructor
Implementation
InlineParser(this.source, this.document) {
// User specified syntaxes are the first syntaxes to be evaluated.
syntaxes.addAll(document.inlineSyntaxes);
// This first RegExp matches plain text to accelerate parsing. It's written
// so that it does not match any prefix of any following syntaxes. Most
// Markdown is plain text, so it's faster to match one RegExp per 'word'
// rather than fail to match all the following RegExps at each non-syntax
// character position.
if (document.hasCustomInlineSyntaxes) {
// We should be less aggressive in blowing past "words".
syntaxes.add(TextSyntax(r'[A-Za-z0-9]+(?=\s)'));
} else {
syntaxes.add(TextSyntax(r'[ \tA-Za-z0-9]*[A-Za-z0-9](?=\s)'));
}
if (document.withDefaultInlineSyntaxes) {
// Custom link resolvers go after the generic text syntax.
syntaxes.addAll([
EscapeSyntax(),
DecodeHtmlSyntax(),
LinkSyntax(linkResolver: document.linkResolver),
ImageSyntax(linkResolver: document.imageLinkResolver)
]);
syntaxes.addAll(_defaultSyntaxes);
}
if (encodeHtml) {
syntaxes.addAll([
EscapeHtmlSyntax(),
// Leave already-encoded HTML entities alone. Ensures we don't turn
// "&" into "&"
TextSyntax('&[#a-zA-Z0-9]*;', startCharacter: $ampersand),
]);
}
}