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.
53 lines
1.0 KiB
53 lines
1.0 KiB
// Skip text characters for text token, place those to pending buffer
|
|
// and increment current pos
|
|
|
|
'use strict';
|
|
|
|
|
|
// Rule to skip pure text
|
|
// '{}$%@~+=:' reserved for extentions
|
|
|
|
function isTerminatorChar(ch) {
|
|
switch (ch) {
|
|
case 0x0A/* \n */:
|
|
case 0x5C/* \ */:
|
|
case 0x60/* ` */:
|
|
case 0x2A/* * */:
|
|
case 0x5F/* _ */:
|
|
case 0x5E/* ^ */:
|
|
case 0x5B/* [ */:
|
|
case 0x5D/* ] */:
|
|
case 0x21/* ! */:
|
|
case 0x26/* & */:
|
|
case 0x3C/* < */:
|
|
case 0x3E/* > */:
|
|
case 0x7B/* { */:
|
|
case 0x7D/* } */:
|
|
case 0x24/* $ */:
|
|
case 0x25/* % */:
|
|
case 0x40/* @ */:
|
|
case 0x7E/* ~ */:
|
|
case 0x2B/* + */:
|
|
case 0x3D/* = */:
|
|
case 0x3A/* : */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
module.exports = function text(state, silent) {
|
|
var pos = state.pos;
|
|
|
|
while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
|
|
pos++;
|
|
}
|
|
|
|
if (pos === state.pos) { return false; }
|
|
|
|
if (!silent) { state.pending += state.src.slice(state.pos, pos); }
|
|
|
|
state.pos = pos;
|
|
|
|
return true;
|
|
};
|
|
|