.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-media-query-parser / README.md
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/postcss-media-query-parser/README.md b/.config/coc/extensions/node_modules/coc-prettier/node_modules/postcss-media-query-parser/README.md
new file mode 100644 (file)
index 0000000..078b319
--- /dev/null
@@ -0,0 +1,173 @@
+# postcss-media-query-parser\r
+\r
+[![NPM version](http://img.shields.io/npm/v/postcss-media-query-parser.svg)](https://www.npmjs.com/package/postcss-media-query-parser) [![Build Status](https://travis-ci.org/dryoma/postcss-media-query-parser.svg?branch=master)](https://travis-ci.org/dryoma/postcss-media-query-parser)\r
+\r
+Media query parser with very simple traversing functionality.\r
+\r
+## Installation and usage\r
+\r
+First install it via NPM:\r
+\r
+```\r
+npm install postcss-media-query-parser\r
+```\r
+\r
+Then in your Node.js application:\r
+\r
+```js\r
+import mediaParser from "postcss-media-query-parser";\r
+\r
+const mediaQueryString = "(max-width: 100px), not print";\r
+const result = mediaParser(mediaQueryString);\r
+```\r
+\r
+The `result` will be this object:\r
+\r
+```js\r
+{\r
+  type: 'media-query-list',\r
+  value: '(max-width: 100px), not print',\r
+  after: '',\r
+  before: '',\r
+  sourceIndex: 0,\r
+\r
+  // the first media query\r
+  nodes: [{\r
+    type: 'media-query',\r
+    value: '(max-width: 100px)',\r
+    before: '',\r
+    after: '',\r
+    sourceIndex: 0,\r
+    parent: <link to parent 'media-query-list' node>,\r
+    nodes: [{\r
+      type: 'media-feature-expression',\r
+      value: '(max-width: 100px)',\r
+      before: '',\r
+      after: '',\r
+      sourceIndex: 0,\r
+      parent: <link to parent 'media-query' node>,\r
+      nodes: [{\r
+        type: 'media-feature',\r
+        value: 'max-width',\r
+        before: '',\r
+        after: '',\r
+        sourceIndex: 1,\r
+        parent: <link to parent 'media-feature-expression' node>,\r
+      }, {\r
+        type: 'colon',\r
+        value: ':',\r
+        before: '',\r
+        after: ' ',\r
+        sourceIndex: 10,\r
+        parent: <link to parent 'media-feature-expression' node>,\r
+      }, {\r
+        type: 'value',\r
+        value: '100px',\r
+        before: ' ',\r
+        after: '',\r
+        sourceIndex: 12,\r
+        parent: <link to parent 'media-feature-expression' node>,\r
+      }]\r
+    }]\r
+  },\r
+  // the second media query\r
+  {\r
+    type: 'media-query',\r
+    value: 'not print',\r
+    before: ' ',\r
+    after: '',\r
+    sourceIndex: 20,\r
+    parent: <link to parent 'media-query-list' node>,\r
+    nodes: [{\r
+      type: 'keyword',\r
+      value: 'not',\r
+      before: ' ',\r
+      after: ' ',\r
+      sourceIndex: 20,\r
+      parent: <link to parent 'media-query' node>,\r
+    }, {\r
+      type: 'media-type',\r
+      value: 'print',\r
+      before: ' ',\r
+      after: '',\r
+      sourceIndex: 24,\r
+      parent: <link to parent 'media-query' node>,\r
+    }]\r
+  }]\r
+}\r
+```\r
+\r
+One of the likely sources of a string to parse would be traversing [a PostCSS container node](http://api.postcss.org/Root.html) and getting the `params` property of nodes with the name of "atRule":\r
+\r
+```js\r
+import postcss from "postcss";\r
+import mediaParser from "postcss-media-query-parser";\r
+\r
+const root = postcss.parse(<contents>);\r
+// ... or any other way to get sucn container\r
+\r
+root.walkAtRules("media", (atRule) => {\r
+  const mediaParsed = mediaParser(atRule.params);\r
+  // Do something with "mediaParsed" object\r
+});\r
+```\r
+\r
+## Nodes\r
+\r
+Node is a very generic item in terms of this parser. It's is pretty much everything that ends up in the parsed result. Each node has these properties:\r
+\r
+* `type`: the type of the node (see below);\r
+* `value`: the node's value stripped of trailing whitespaces;\r
+* `sourceIndex`: 0-based index of the node start relative to the source start (excluding trailing whitespaces);\r
+* `before`: a string that contain a whitespace between the node start and the previous node end/source start;\r
+* `after`: a string that contain a whitespace between the node end and the next node start/source end;\r
+* `parent`: a link to this node's parent node (a container).\r
+\r
+A node can have one of these types (according to [the 2012 CSS3 standard](https://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/)):\r
+\r
+* `media-query-list`: that is the root level node of the parsing result. A [container](#containers); its children can have types of `url` and `media-query`.\r
+* `url`: if a source is taken from a CSS `@import` rule, it will have a `url(...)` function call. The value of such node will be `url(http://uri-address)`, it is to be parsed separately.\r
+* `media-query`: such nodes correspond to each media query in a comma separated list. In the exapmle above there are two. Nodes of this type are [containers](#containers).\r
+* `media-type`: `screen`, `tv` and other media types.\r
+* `keyword`: `only`, `not` or `and` keyword.\r
+* `media-feature-expression`: an expression in parentheses that checks for a condition of a particular media feature. The value would be like this: `(max-width: 1000px)`. Such nodes are [containers](#containers). They always have a `media-feature` child node, but might not have a `value` child node (like in `screen and (color)`).\r
+* `media-feature`: a media feature, e.g. `max-width`.\r
+* `colon`: present if a media feature expression has a colon (e.g. `(min-width: 1000px)`, compared to `(color)`).\r
+* `value`: a media feature expression value, e.g. `100px` in `(max-width: 1000px)`.\r
+\r
+### Parsing details\r
+\r
+postcss-media-query-parser allows for cases of some **non-standard syntaxes** and tries its best to work them around. For example, in a media query from a code with SCSS syntax:\r
+\r
+```scss\r
+@media #{$media-type} and ( #{"max-width" + ": 10px"} ) { ... }\r
+```\r
+\r
+`#{$media-type}` will be the node of type `media-type`, alghough `$media-type`'s value can be `only screen`. And inside `media-feature-expression` there will only be a `media-feature` type node with the value of `#{"max-width" + ": 10px"}` (this example doesn't make much sense, it's for demo purpose).\r
+\r
+But the result of parsing **malformed media queries** (such as with incorrect amount of closing parens, curly braces, etc.) can be unexpected. For exapmle, parsing:\r
+\r
+```scss\r
+@media ((min-width: -100px)\r
+```\r
+\r
+would return a media query list with the single `media-query` node that has no child nodes.\r
+\r
+## Containers\r
+\r
+Containers are [nodes](#nodes) that have other nodes as children. Container nodes have an additional property `nodes` which is an array of their child nodes. And also these methods:\r
+\r
+* `each(callback)` - traverses the direct child nodes of a container, calling `callback` function for each of them. Returns `false` if traversing has stopped by means of `callback` returning `false`, and `true` otherwise.\r
+* `walk([filter, ]callback)` - traverses ALL descendant nodes of a container, calling `callback` function for each of them. Returns `false` if traversing has stopped by means of `callback` returning `false`, and `true` otherwise.\r
+\r
+In both cases `callback` takes these parameters:\r
+\r
+- `node` - the current node (one of the container's descendats, that the callback has been called against).\r
+- `i` - 0-based index of the `node` in an array of its parent's children.\r
+- `nodes` - array of child nodes of `node`'s parent.\r
+\r
+If `callback` returns `false`, the traversing stops.\r
+\r
+## License\r
+\r
+MIT\r