1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 04:17:33 -04:00
notes/node_modules/postcss-less/dist/tokenizer/find-end-of-escaping.js

38 lines
998 B
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findEndOfEscaping;
var _globals = require('./globals');
/**
* @param state
* @returns {number}
*/
function findEndOfEscaping(state) {
var openQuotesCount = 0;
var quoteCode = -1;
for (var i = state.pos + 1; i < state.length; i++) {
var symbolCode = state.css.charCodeAt(i);
var prevSymbolCode = state.css.charCodeAt(i - 1);
if (prevSymbolCode !== _globals.backslash && (symbolCode === _globals.singleQuote || symbolCode === _globals.doubleQuote || symbolCode === _globals.backTick)) {
if (quoteCode === -1) {
quoteCode = symbolCode;
openQuotesCount++;
} else if (symbolCode === quoteCode) {
openQuotesCount--;
if (!openQuotesCount) {
return i;
}
}
}
}
return -1;
}
module.exports = exports['default'];