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.
33 lines
664 B
33 lines
664 B
10 years ago
|
// Proceess '\n'
|
||
|
|
||
|
module.exports = function escape(state) {
|
||
|
var pmax, pos = state.pos;
|
||
|
|
||
|
if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
|
||
|
|
||
|
pmax = state.pending.length - 1;
|
||
|
|
||
|
// ' \n' -> hardbreak
|
||
|
if (pmax >= 1 &&
|
||
|
state.pending.charCodeAt(pmax) === 0x20 &&
|
||
|
state.pending.charCodeAt(pmax - 1) === 0x20) {
|
||
|
state.pending = state.pending.slice(0, -2);
|
||
|
state.push({
|
||
|
type: 'hardbreak'
|
||
|
});
|
||
|
state.pos++;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
state.pending = state.pending.trim() + '\n';
|
||
|
|
||
|
pos++;
|
||
|
|
||
|
// skip spaces to simplify trim
|
||
|
while (state.src.charCodeAt(pos) === 0x20) { pos++; }
|
||
|
|
||
|
state.pos = pos;
|
||
|
|
||
|
return true;
|
||
|
};
|