Class: Parser
Defined in: parser/parser.ts:68
Extended by
Constructors
Constructor
new Parser(): Parser;Returns
Parser
Properties
block
block: ParserBlock<Parser>;Defined in: parser/parser.ts:77
Instance of ParserBlock. You may need it to add new rules when writing plugins.
core
core: Core<Parser>;Defined in: parser/parser.ts:82
Instance of Core chain executor. You may need it to add new rules when writing plugins.
helpers
helpers: object;Defined in: parser/parser.ts:120
Link components parser functions, useful to write plugins. See details here.
parseLinkDestination()
parseLinkDestination: (str, start, max) => ParseLinkDestinationResult;Parameters
str
string
start
number
max
number
Returns
ParseLinkDestinationResult
parseLinkLabel()
parseLinkLabel: (state, start, disableNested) => number;Parameters
state
StateInline
start
number
disableNested
boolean = false
Returns
number
parseLinkTitle()
parseLinkTitle: (str, start, max, prev_state?) => ParseLinkTitleResult;Parameters
str
string
start
number
max
number
prev_state?
ParseLinkTitleResult
Returns
ParseLinkTitleResult
inline
inline: ParserInline<Parser>;Defined in: parser/parser.ts:72
Instance of ParserInline. You may need it to add new rules when writing plugins.
linkify
linkify: LinkifyIt;Defined in: parser/parser.ts:89
linkify-it instance. Used by linkify rule.
normalizeLink()
normalizeLink: (url) => string;Defined in: parser/parser.ts:109
Function used to encode link url to a machine-readable format, which includes url-encoding, punycode, etc.
Parameters
url
string
Returns
string
normalizeLinkText()
normalizeLinkText: (url) => string;Defined in: parser/parser.ts:114
Function used to decode link url to a human-readable format`
Parameters
url
string
Returns
string
options
options: Required<ParserOptions>;Defined in: parser/parser.ts:122
validateLink()
validateLink: (url) => boolean;Defined in: parser/parser.ts:103
Link validation function. CommonMark allows too much in links. By default we disable javascript:, vbscript:, file: schemas, and almost all data:... schemas except some embedded image types.
You can change this behaviour:
// enable everything
md.validateLink = () => trueParameters
url
string
Returns
boolean
Methods
parse()
parse(src, env): Token[];Defined in: parser/parser.ts:138
Parse input string and returns list of block tokens (special token type "inline" will contain list of inline tokens). You should not call this method directly, until you write custom renderer (for example, to produce AST).
env is used to pass data between "distributed" rules and return additional metadata like reference info, needed for the renderer. It also can be used to inject data in specific cases. Usually, you will be ok to pass {}, and then pass updated object to renderer.
Parameters
src
string
source string
env
MarkdownExitEnv = {}
environment sandbox
Returns
Token[]
parseInline()
parseInline(src, env): Token[];Defined in: parser/parser.ts:155
The same as parse but skip all block rules. It returns the block tokens list with the single inline element, containing parsed inline tokens in children property. Also updates env object.
Parameters
src
string
source string
env
MarkdownExitEnv = {}
environment sandbox
Returns
Token[]