nl_tokens: Extracts single CSS selector definition from source code
pl_tokens: function ( content , pos , isBackward ) { var result = '' ; var len = content . length ; var offset = pos ; var stopChars = '{}/\\<>\n\r' ; var bracePos = - 1 , ch ; // search left until we find rule edge while ( offset >= 0 ) { ch = <mask> . charAt ( offset ) ; if ( ch == '{' ) { bracePos = offset ; break ; } else if ( ch == '}' && ! isBackward ) { offset ++ ; break ; } offset -- ; } // search right for full rule set while ( offset < len ) { ch = content . charAt ( offset ) ; if ( ch == '{' ) { bracePos = offset ; } else if ( ch == '}' ) { if ( bracePos != - 1 ) result = content . substring ( bracePos , offset + 1 ) ; break ; } offset ++ ; } if ( result ) { // find CSS selector offset = bracePos - 1 ; var selector = '' ; while ( offset >= 0 ) { ch = content . charAt ( offset ) ; if ( stopChars . indexOf ( ch ) != - 1 ) break ; offset -- ; } // also trim whitespace selector = content . substring ( offset + 1 , bracePos ) . replace ( / ^[\s\n\r]+ / m , '' ) ; return require ( 'range' ) . create ( bracePos - selector . length , result . length + selector . length ) ; } return null ; }