Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
https://markdown-it.github.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
787 B
39 lines
787 B
// Inline parser state
|
|
|
|
'use strict';
|
|
|
|
|
|
function StateInline(src, lexer, options) {
|
|
this.src = src;
|
|
this.options = options;
|
|
this.lexer = lexer;
|
|
this.tokens = [];
|
|
this.pos = 0;
|
|
this.pending = '';
|
|
this.posMax = this.src.length;
|
|
}
|
|
|
|
|
|
StateInline.prototype.pushText = function () {
|
|
var pending = this.pending;
|
|
// strip leading spaces from the first token.
|
|
// others will be stripped by logic in `newline` rule
|
|
if (this.tokens.length === 0 && pending.charCodeAt(0) === 0x20) {
|
|
pending = pending.replace(/^ +/, '');
|
|
}
|
|
this.tokens.push({
|
|
type: 'text',
|
|
content: pending
|
|
});
|
|
this.pending = '';
|
|
};
|
|
|
|
StateInline.prototype.push = function (token) {
|
|
if (this.pending) {
|
|
this.pushText();
|
|
}
|
|
|
|
this.tokens.push(token);
|
|
};
|
|
|
|
module.exports = StateInline;
|
|
|