1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 06:27:23 -04:00
notes/node_modules/postcss-less/dist/tokenizer/tokenize-opened-parenthesis.min.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

1 line
1.7 KiB
JavaScript

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function findClosedParenthesisPosition(e,s,o){for(var t=0,n=o;n<s;n++){var l=e[n];if("("===l)t++;else if(")"===l&&(t--,!t))return n}return-1}function tokenizeOpenedParenthesis(e){var s=e.css.charCodeAt(e.pos+1),o=e.tokens.length,t=o?e.tokens[o-1][1]:"";if("url"===t&&s!==_globals.singleQuote&&s!==_globals.doubleQuote&&s!==_globals.space&&s!==_globals.newline&&s!==_globals.tab&&s!==_globals.feed&&s!==_globals.carriageReturn){e.nextPos=e.pos;do for(e.escaped=!1,e.nextPos=e.css.indexOf(")",e.nextPos+1),e.nextPos===-1&&(0,_unclosed2["default"])(e,"bracket"),e.escapePos=e.nextPos;e.css.charCodeAt(e.escapePos-1)===_globals.backslash;)e.escapePos-=1,e.escaped=!e.escaped;while(e.escaped);e.tokens.push(["brackets",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}else{e.nextPos=findClosedParenthesisPosition(e.css,e.length,e.pos),e.cssPart=e.css.slice(e.pos,e.nextPos+1);var n=e.cssPart.indexOf("@")>=0,l=/['"]/.test(e.cssPart);if(0===e.cssPart.length||"..."===e.cssPart||n&&!l)e.nextPos===-1&&(0,_unclosed2["default"])(e,"bracket"),e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]);else{var a=_globals.badBracketPattern.test(e.cssPart);e.nextPos===-1||a?e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]):(e.tokens.push(["brackets",e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos)}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeOpenedParenthesis;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];