mirror of https://github.com/lukechilds/node.git
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.
43 lines
818 B
43 lines
818 B
/**
|
|
* @author Titus Wormer
|
|
* @copyright 2015 Titus Wormer
|
|
* @license MIT
|
|
* @module remark:parse:tokenize:escape
|
|
* @fileoverview Tokenise an escape.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var locate = require('../locate/escape');
|
|
|
|
module.exports = escape;
|
|
escape.locator = locate;
|
|
|
|
/* Tokenise an escape. */
|
|
function escape(eat, value, silent) {
|
|
var self = this;
|
|
var character;
|
|
var node;
|
|
|
|
if (value.charAt(0) === '\\') {
|
|
character = value.charAt(1);
|
|
|
|
if (self.escape.indexOf(character) !== -1) {
|
|
/* istanbul ignore if - never used (yet) */
|
|
if (silent) {
|
|
return true;
|
|
}
|
|
|
|
if (character === '\n') {
|
|
node = {type: 'break'};
|
|
} else {
|
|
node = {
|
|
type: 'text',
|
|
value: character
|
|
};
|
|
}
|
|
|
|
return eat('\\' + character)(node);
|
|
}
|
|
}
|
|
}
|
|
|