|
|
@ -3,16 +3,51 @@ |
|
|
|
|
|
|
|
'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 str = state.src.slice(state.pos), |
|
|
|
next = str.search(state.parser.textMatch); |
|
|
|
var pos = state.pos; |
|
|
|
|
|
|
|
while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) { |
|
|
|
pos++; |
|
|
|
} |
|
|
|
|
|
|
|
if (next === 0) { return false; } |
|
|
|
if (pos === state.pos) { return false; } |
|
|
|
|
|
|
|
if (next < 0) { next = str.length; } |
|
|
|
if (!silent) { state.pending += state.src.slice(state.pos, pos); } |
|
|
|
|
|
|
|
if (!silent) { state.pending += str.slice(0, next); } |
|
|
|
state.pos += next; |
|
|
|
state.pos = pos; |
|
|
|
|
|
|
|
return true; |
|
|
|
}; |
|
|
|