Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

README.md 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # style-search [![CircleCI](https://circleci.com/gh/davidtheclark/style-search.svg?style=svg)](https://circleci.com/gh/davidtheclark/style-search)
  2. Search CSS (and CSS-like) strings, with sensitivity to whether matches occur inside strings, comments, and functions.
  3. ## Usage
  4. ```js
  5. var styleSearch = require('style-search');
  6. styleSearch(options, callback);
  7. ```
  8. **By default, the search ignores strings, comments, and function names.** You can use the options to change this behavior or introduce other restrictions. That is what makes this module more useful for many searches than `indexOf()` or a `RegExp`.
  9. However, if you need more detailed parsing, you should consider using the real parsers [PostCSS](https://github.com/postcss/postcss), [`postcss-selector-parser`](https://github.com/postcss/postcss-selector-parser), and [`postcss-value-parser`](https://github.com/TrySound/postcss-value-parser).
  10. ### Example
  11. ```css
  12. /* Here is some pink */
  13. a { color: pink; }
  14. a::before { content: "pink" }
  15. b { color: shadesOfPink(7); }
  16. ```
  17. ```js
  18. styleSearch({
  19. source: theCssStringAbove,
  20. target: "pink",
  21. }, function(match, count) {
  22. /* Only the "pink" in `color: pink` will be
  23. reported as a match */
  24. });
  25. ```
  26. ### Reporting matches
  27. For every match found your `callback` is invoked. It is passed two arguments:
  28. - A `match` object with the following properties:
  29. - `startIndex`: where the match begins
  30. - `endIndex`: where the match ends
  31. - `target`: what got matched (useful if your `target` option is an array instead of a single string)
  32. - `insideFunctionArguments`: whether the match is inside a function — *this includes the parentheses around the arguments*
  33. - `insideComment`: whether the match is inside a comment
  34. - `insideString`: whether the match is inside a string
  35. - The count of how many matches have been found up to this point.
  36. ### Options
  37. Below you'll see that syntax feature options all accept three keywords: `"skip"`, `"check"`, `"only"`. An error will be thrown if you use `"only"` more than once.
  38. #### source
  39. String. *Required.*
  40. The source string to search through.
  41. #### target
  42. String or array of strings. *Required.*
  43. The target of the search. Can be
  44. - a single character
  45. - a string with some length
  46. - an array of strings, all of which count as matches (the `match` object passed to the `callback` will differentiate which string in the array got matched via its `target` property)
  47. #### once
  48. Boolean. Default: `false`.
  49. If `true`, the search will stop after one match is found.
  50. #### comments
  51. `"skip"` | `"check"` | `"only"`. Default: `"skip"`.
  52. This includes both standard `/* CSS comments */` and non-standard but widely used `// single line comments`.
  53. #### strings
  54. `"skip"` | `"check"` | `"only"`. Default: `"skip"`.
  55. #### functionNames
  56. `"skip"` | `"check"` | `"only"`. Default: `"skip"`.
  57. #### functionArguments
  58. `"skip"` | `"check"` | `"only"`. Default: `"check"`.
  59. #### parentheticals
  60. `"skip"` | `"check"` | `"only"`. Default: `"check"`.
  61. This designates anything inside parentheses, which includes standard functions, but also Sass maps and other non-standard constructs. `parentheticals` is a broader category than `functionArguments`.