Provides

Standalone CSS3 Selector parser

  1. 10
  2. 11
  3. 12
  4. 13
  5. 14
  6. 15
  7. 16
  8. 17
  9. 18
  10. 19
  11. 20
  12. 21
  13. 22
  14. 23
  15. 24
  16. 25
  17. 26
  18. 27
  19. 28
  20. 29
  21. 30
  22. 31
  23. 32
  24. 33
  25. 34
  26. 35
  27. 36
  28. 37
  29. 38
  30. 39
  31. 40
  32. 41
  33. 42
  34. 43
  35. 44
  36. 45
  37. 46
  38. 47
  39. 48
  40. 49
  41. 50
  42. 51
  43. 52
  44. 53
  45. 54
  46. 55
  47. 56
  48. 57
  49. 58
  50. 59
  51. 60
  52. 61
  53. 62
  54. 63
  55. 64
  56. 65
(function(){ var parsed, separatorIndex, combinatorIndex, reversed, cache = {}, reverseCache = {}, reUnescape = /\\/g; var parse = function(expression, isReversed){ if (expression == null) return null; if (expression.Slick === true) return expression; expression = ('' + expression).replace(/^\s+|\s+$/g, ''); reversed = !!isReversed; var currentCache = (reversed) ? reverseCache : cache; if (currentCache[expression]) return currentCache[expression]; parsed = {Slick: true, expressions: [], raw: expression, reverse: function(){ return parse(this.raw, true); }}; separatorIndex = -1; while (expression != (expression = expression.replace(regexp, parser))); parsed.length = parsed.expressions.length; return currentCache[expression] = (reversed) ? reverse(parsed) : parsed; }; var reverseCombinator = function(combinator){ if (combinator === '!') return ' '; else if (combinator === ' ') return '!'; else if ((/^!/).test(combinator)) return combinator.replace(/^!/, ''); else return '!' + combinator; }; var reverse = function(expression){ var expressions = expression.expressions; for (var i = 0; i < expressions.length; i++){ var exp = expressions[i]; var last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)}; for (var j = 0; j < exp.length; j++){ var cexp = exp[j]; if (!cexp.reverseCombinator) cexp.reverseCombinator = ' '; cexp.combinator = cexp.reverseCombinator; delete cexp.reverseCombinator; } exp.reverse().push(last); } return expression; }; var escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); }; var regexp = new RegExp(

!/usr/bin/env ruby

puts “\t\t” + DATA.read.gsub(/(\?x)|\s+#.$|\s+|\$|\n/,‘’) END “(?x)(?:\ \s ( , ) \s # Separator \n\ | \s ( + ) \s # Combinator \n\ | ( \s+ ) # CombinatorChildren \n\ | ( + | \ ) # Tag \n\ | \# ( + ) # ID \n\ | \. ( + ) # ClassName \n\ | # Attribute \n\ \[ \ \s (+) (?: \ \s ([$!~|]?=) (?: \ \s (?:\ ([\”‘]?)(.?)\9 \ )\ ) \ )? \s \ \](?!\]) \n\ | :+ ( + )(?:\ \( (?:\ (?:([\“’])([\12]*)\12)|((?:\([)]+\)|[()]*)+)\ ) \)\ )?\ )”

  1. 94
  2. 95
  3. 96
  4. 97
  5. 98
  6. 99
  7. 100
  8. 101
  9. 102
  10. 103
  11. 104
  12. 105
  13. 106
  14. 107
  15. 108
  16. 109
  17. 110
  18. 111
  19. 112
  20. 113
  21. 114
  22. 115
  23. 116
  24. 117
  25. 118
  26. 119
  27. 120
  28. 121
  29. 122
  30. 123
  31. 124
  32. 125
  33. 126
  34. 127
  35. 128
  36. 129
  37. 130
  38. 131
  39. 132
  40. 133
  41. 134
  42. 135
  43. 136
  44. 137
  45. 138
  46. 139
  47. 140
  48. 141
  49. 142
  50. 143
  51. 144
  52. 145
  53. 146
  54. 147
  55. 148
  56. 149
  57. 150
  58. 151
  59. 152
  60. 153
  61. 154
  62. 155
  63. 156
  64. 157
  65. 158
  66. 159
  67. 160
  68. 161
  69. 162
  70. 163
  71. 164
  72. 165
  73. 166
  74. 167
  75. 168
  76. 169
  77. 170
  78. 171
  79. 172
  80. 173
  81. 174
  82. 175
  83. 176
  84. 177
  85. 178
  86. 179
  87. 180
  88. 181
  89. 182
  90. 183
  91. 184
  92. 185
  93. 186
  94. 187
  95. 188
  96. 189
  97. 190
  98. 191
  99. 192
  100. 193
  101. 194
  102. 195
  103. 196
  104. 197
  105. 198
  106. 199
  107. 200
  108. 201
  109. 202
  110. 203
  111. 204
  112. 205
  113. 206
  114. 207
  115. 208
"^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|:+(<unicode>+)(?:\\((?:(?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+))\\))?)" .replace(/<combinator>/, '[' + escapeRegExp(">+~`!@$%^&={}\\;</") + ']') .replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') .replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') ); function parser( rawMatch, separator, combinator, combinatorChildren, tagName, id, className, attributeKey, attributeOperator, attributeQuote, attributeValue, pseudoClass, pseudoQuote, pseudoClassQuotedValue, pseudoClassValue ){ if (separator || separatorIndex === -1){ parsed.expressions[++separatorIndex] = []; combinatorIndex = -1; if (separator) return ''; } if (combinator || combinatorChildren || combinatorIndex === -1){ combinator = combinator || ' '; var currentSeparator = parsed.expressions[separatorIndex]; if (reversed && currentSeparator[combinatorIndex]) currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator); currentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'}; } var currentParsed = parsed.expressions[separatorIndex][combinatorIndex]; if (tagName){ currentParsed.tag = tagName.replace(reUnescape, ''); } else if (id){ currentParsed.id = id.replace(reUnescape, ''); } else if (className){ className = className.replace(reUnescape, ''); if (!currentParsed.classList) currentParsed.classList = []; if (!currentParsed.classes) currentParsed.classes = []; currentParsed.classList.push(className); currentParsed.classes.push({ value: className, regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)') }); } else if (pseudoClass){ pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue; pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null; if (!currentParsed.pseudos) currentParsed.pseudos = []; currentParsed.pseudos.push({ key: pseudoClass.replace(reUnescape, ''), value: pseudoClassValue }); } else if (attributeKey){ attributeKey = attributeKey.replace(reUnescape, ''); attributeValue = (attributeValue || '').replace(reUnescape, ''); var test, regexp; switch (attributeOperator){ case '^=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) ); break; case '$=' : regexp = new RegExp( escapeRegExp(attributeValue) +'$' ); break; case '~=' : regexp = new RegExp( '(^|\\s)'+ escapeRegExp(attributeValue) +'(\\s|$)' ); break; case '|=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) +'(-|$)' ); break; case '=' : test = function(value){ return attributeValue == value; }; break; case '*=' : test = function(value){ return value && value.indexOf(attributeValue) > -1; }; break; case '!=' : test = function(value){ return attributeValue != value; }; break; default : test = function(value){ return !!value; }; } if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){ return false; }; if (!test) test = function(value){ return value && regexp.test(value); }; if (!currentParsed.attributes) currentParsed.attributes = []; currentParsed.attributes.push({ key: attributeKey, operator: attributeOperator, value: attributeValue, test: test }); } return ''; };

Slick NS

  1. 212
  2. 213
  3. 214
  4. 215
  5. 216
  6. 217
  7. 218
  8. 219
  9. 220
  10. 221
  11. 222
var Slick = (this.Slick || {}); Slick.parse = function(expression){ return parse(expression); }; Slick.escapeRegExp = escapeRegExp; if (!this.Slick) this.Slick = Slick; }).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);