diff --git a/.gitignore b/.gitignore index abad1f9..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ node_modules -test.js -test.css diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 4a3c398..0000000 --- a/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -support -test -examples -*.sock -test.css -test.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09d3ef3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.8 - - 0.10 diff --git a/History.md b/History.md index a04af9e..4a93ca7 100644 --- a/History.md +++ b/History.md @@ -1,53 +1,78 @@ +2.0.0 / 2014-06-18 +================== + + * update 'css' to 2.0.0 + * depend on the 'css' package, which now contains the parser + +1.7.0 / 2013-12-21 +================== + + * allow # in property names + * report filename in errors if available + +1.6.0 / 2013-10-16 +================== + + * add @host support. Closes #54 + * add benchmarks + * add `source` property to `position` + * change: relax keyframe selectors and property names + +1.5.3 / 2013-09-10 +================== + + * add trim shim function. Closes #45 + * fix: parser now correctly parses attributes with whitespace before colon -1.5.2 / 2013-07-28 +1.5.2 / 2013-07-28 ================== * fix another regexp for good old FF -1.5.1 / 2013-07-23 +1.5.1 / 2013-07-23 ================== * fix // declaration hack. Closes #42 * fix comments for several nodes (#34). -1.5.0 / 2013-06-18 +1.5.0 / 2013-06-18 ================== * add error reporting * fix @document with no vendor prefix -1.4.0 / 2013-05-22 +1.4.0 / 2013-05-22 ================== - * add `position` option support + * add `position` option support * add .type to all nodes. Closes #18 * fix comments within rulesets. Closes #30 * fix handling of unterminated comment. Closes #24 -1.3.0 / 2013-05-21 +1.3.0 / 2013-05-21 ================== * add @document parsing. Closes #29 -1.2.0 / 2013-03-28 +1.2.0 / 2013-03-28 ================== * add support for @page at-rules with nested @margin at-rules. * add @namespace support. * add support for new @supports at-rule. -1.1.0 / 2013-03-18 +1.1.0 / 2013-03-18 ================== * add comment parsing -1.0.4 / 2012-09-17 +1.0.4 / 2012-09-17 ================== * fix keyframes float percentages * fix an issue with comments containing slashes. -1.0.3 / 2012-09-01 +1.0.3 / 2012-09-01 ================== * add component support @@ -55,13 +80,13 @@ * fix keyframe names with no whitespace [rstacruz] * fix excess semicolon support [rstacruz] -1.0.2 / 2012-09-01 +1.0.2 / 2012-09-01 ================== * fix IE property hack support [rstacruz] * fix quoted strings in declarations [rstacruz] -1.0.1 / 2012-07-26 +1.0.1 / 2012-07-26 ================== * change "selector" to "selectors" array diff --git a/Makefile b/Makefile deleted file mode 100644 index d78a055..0000000 --- a/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec \ - --bail - -.PHONY: test diff --git a/Readme.md b/Readme.md index 1c05b32..99a4743 100644 --- a/Readme.md +++ b/Readme.md @@ -1,112 +1,14 @@ - # css-parse - JavaScript CSS parser for nodejs and the browser. - -## Example - -css: - -```css -body { - background: #eee; - color: #888; -} -``` - -parse tree: - -```json -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "#eee" - }, - { - "type": "declaration", - "property": "color", - "value": "#888" - } - ] - } - ] - } -} -``` + JavaScript CSS parser for Node.js (exports the `parse` method of [css](https://github.com/reworkcss/css)) -parse tree with `.position` enabled: +## Installation -```json -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "#eee", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 19 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "#888", - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 14 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 5, - "column": 2 - } - } - } - ] - } -} -``` + $ npm install css-parse -## Performance +## Usage - Parsed 15,000 lines of CSS (2mb) in 40ms on my macbook air. + Please see the [css](https://github.com/reworkcss/css) module documentation. ## License diff --git a/component.json b/component.json deleted file mode 100644 index 5c6ce0c..0000000 --- a/component.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "css-parse", - "repo": "visionmedia/css-parse", - "version": "1.5.2", - "description": "CSS parser", - "keywords": ["css", "parser", "stylesheet"], - "scripts": ["index.js"] -} diff --git a/examples/dialog.css b/examples/dialog.css deleted file mode 100644 index df74183..0000000 --- a/examples/dialog.css +++ /dev/null @@ -1,92 +0,0 @@ -#dialog { - position: fixed; - left: 50%; - top: 150px; - max-width: 600px; - min-width: 250px; - border: 1px solid #eee; - background: white; - z-index: 1000; -} - -#dialog .content { - padding: 15px 20px; -} - -#dialog h1 { - margin: 0 0 5px 0; - font-size: 16px; - font-weight: normal; -} - -#dialog p { - margin: 0; - padding: 0; - font-size: .9em; -} - -#dialog.modal { - box-shadow: 0 1px 8px 0 black; -} - -/* close */ - -#dialog .close { - position: absolute; - top: 3px; - right: 10px; - text-decoration: none; - color: #888; - font-size: 16px; - font-weight: bold; - display: none; -} - -#dialog.closable .close { - display: block; -} - -#dialog .close:hover { - color: black; -} - -#dialog .close:active { - margin-top: 1px; -} - -/* slide */ - -#dialog.slide { - -webkit-transition: opacity 300ms, top 300ms; - -moz-transition: opacity 300ms, top 300ms; -} - -#dialog.slide.hide { - opacity: 0; - top: -500px; -} - -/* fade */ - -#dialog.fade { - -webkit-transition: opacity 300ms; - -moz-transition: opacity 300ms; -} - -#dialog.fade.hide { - opacity: 0; -} - -/* scale */ - -#dialog.scale { - -webkit-transition: -webkit-transform 300ms; - -moz-transition: -moz-transform 300ms; - -webkit-transform: scale(1); - -moz-transform: scale(1); -} - -#dialog.scale.hide { - -webkit-transform: scale(0); - -moz-transform: scale(0); -} \ No newline at end of file diff --git a/examples/dialog.js b/examples/dialog.js deleted file mode 100644 index f115a16..0000000 --- a/examples/dialog.js +++ /dev/null @@ -1,11 +0,0 @@ - -/** - * Module dependencies. - */ - -var parse = require('..') - , fs = require('fs') - , read = fs.readFileSync - , css = read('examples/dialog.css', 'utf8'); - -console.log(JSON.stringify(parse(css), null, 2)); \ No newline at end of file diff --git a/index.js b/index.js index 99c4806..32c8634 100644 --- a/index.js +++ b/index.js @@ -1,460 +1 @@ - -module.exports = function(css, options){ - options = options || {}; - - /** - * Positional. - */ - - var lineno = 1; - var column = 1; - - /** - * Update lineno and column based on `str`. - */ - - function updatePosition(str) { - var lines = str.match(/\n/g); - if (lines) lineno += lines.length; - var i = str.lastIndexOf('\n'); - column = ~i ? str.length - i : column + str.length; - } - - /** - * Mark position and patch `node.position`. - */ - - function position() { - var start = { line: lineno, column: column }; - if (!options.position) return positionNoop; - - return function(node){ - node.position = { - start: start, - end: { line: lineno, column: column } - }; - - whitespace(); - return node; - } - } - - /** - * Return `node`. - */ - - function positionNoop(node) { - whitespace(); - return node; - } - - /** - * Error `msg`. - */ - - function error(msg) { - var err = new Error(msg + ' near line ' + lineno + ':' + column); - err.line = lineno; - err.column = column; - err.source = css; - throw err; - } - - /** - * Parse stylesheet. - */ - - function stylesheet() { - return { - type: 'stylesheet', - stylesheet: { - rules: rules() - } - }; - } - - /** - * Opening brace. - */ - - function open() { - return match(/^{\s*/); - } - - /** - * Closing brace. - */ - - function close() { - return match(/^}/); - } - - /** - * Parse ruleset. - */ - - function rules() { - var node; - var rules = []; - whitespace(); - comments(rules); - while (css.charAt(0) != '}' && (node = atrule() || rule())) { - rules.push(node); - comments(rules); - } - return rules; - } - - /** - * Match `re` and return captures. - */ - - function match(re) { - var m = re.exec(css); - if (!m) return; - var str = m[0]; - updatePosition(str); - css = css.slice(str.length); - return m; - } - - /** - * Parse whitespace. - */ - - function whitespace() { - match(/^\s*/); - } - - /** - * Parse comments; - */ - - function comments(rules) { - var c; - rules = rules || []; - while (c = comment()) rules.push(c); - return rules; - } - - /** - * Parse comment. - */ - - function comment() { - var pos = position(); - if ('/' != css.charAt(0) || '*' != css.charAt(1)) return; - - var i = 2; - while (null != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i; - i += 2; - - var str = css.slice(2, i - 2); - column += 2; - updatePosition(str); - css = css.slice(i); - column += 2; - - return pos({ - type: 'comment', - comment: str - }); - } - - /** - * Parse selector. - */ - - function selector() { - var m = match(/^([^{]+)/); - if (!m) return; - return m[0].replace(/^\s+|\s+$/g, '').split(/\s*,\s*/); - } - - /** - * Parse declaration. - */ - - function declaration() { - var pos = position(); - - // prop - var prop = match(/^(\*?[-\/\*\w]+)\s*/); - if (!prop) return; - prop = prop[0]; - - // : - if (!match(/^:\s*/)) return error("property missing ':'"); - - // val - var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); - if (!val) return error('property missing value'); - - var ret = pos({ - type: 'declaration', - property: prop, - value: val[0].replace(/^\s+|\s+$/g, '') - }); - - // ; - match(/^[;\s]*/); - - return ret; - } - - /** - * Parse declarations. - */ - - function declarations() { - var decls = []; - - if (!open()) return error("missing '{'"); - comments(decls); - - // declarations - var decl; - while (decl = declaration()) { - decls.push(decl); - comments(decls); - } - - if (!close()) return error("missing '}'"); - return decls; - } - - /** - * Parse keyframe. - */ - - function keyframe() { - var m; - var vals = []; - var pos = position(); - - while (m = match(/^(from|to|\d+%|\.\d+%|\d+\.\d+%)\s*/)) { - vals.push(m[1]); - match(/^,\s*/); - } - - if (!vals.length) return; - - return pos({ - type: 'keyframe', - values: vals, - declarations: declarations() - }); - } - - /** - * Parse keyframes. - */ - - function atkeyframes() { - var pos = position(); - var m = match(/^@([-\w]+)?keyframes */); - - if (!m) return; - var vendor = m[1]; - - // identifier - var m = match(/^([-\w]+)\s*/); - if (!m) return error("@keyframes missing name"); - var name = m[1]; - - if (!open()) return error("@keyframes missing '{'"); - - var frame; - var frames = comments(); - while (frame = keyframe()) { - frames.push(frame); - frames = frames.concat(comments()); - } - - if (!close()) return error("@keyframes missing '}'"); - - return pos({ - type: 'keyframes', - name: name, - vendor: vendor, - keyframes: frames - }); - } - - /** - * Parse supports. - */ - - function atsupports() { - var pos = position(); - var m = match(/^@supports *([^{]+)/); - - if (!m) return; - var supports = m[1].replace(/^\s+|\s+$/g, ''); - - if (!open()) return error("@supports missing '{'"); - - var style = comments().concat(rules()); - - if (!close()) return error("@supports missing '}'"); - - return pos({ - type: 'supports', - supports: supports, - rules: style - }); - } - - /** - * Parse media. - */ - - function atmedia() { - var pos = position(); - var m = match(/^@media *([^{]+)/); - - if (!m) return; - var media = m[1].replace(/^\s+|\s+$/g, ''); - - if (!open()) return error("@media missing '{'"); - - var style = comments().concat(rules()); - - if (!close()) return error("@media missing '}'"); - - return pos({ - type: 'media', - media: media, - rules: style - }); - } - - /** - * Parse paged media. - */ - - function atpage() { - var pos = position(); - var m = match(/^@page */); - if (!m) return; - - var sel = selector() || []; - - if (!open()) return error("@page missing '{'"); - var decls = comments(); - - // declarations - var decl; - while (decl = declaration()) { - decls.push(decl); - decls = decls.concat(comments()); - } - - if (!close()) return error("@page missing '}'"); - - return pos({ - type: 'page', - selectors: sel, - declarations: decls - }); - } - - /** - * Parse document. - */ - - function atdocument() { - var pos = position(); - var m = match(/^@([-\w]+)?document *([^{]+)/); - if (!m) return; - - var vendor = (m[1] || '').replace(/^\s+|\s+$/g, ''); - var doc = m[2].replace(/^\s+|\s+$/g, ''); - - if (!open()) return error("@document missing '{'"); - - var style = comments().concat(rules()); - - if (!close()) return error("@document missing '}'"); - - return pos({ - type: 'document', - document: doc, - vendor: vendor, - rules: style - }); - } - - /** - * Parse import - */ - - function atimport() { - return _atrule('import'); - } - - /** - * Parse charset - */ - - function atcharset() { - return _atrule('charset'); - } - - /** - * Parse namespace - */ - - function atnamespace() { - return _atrule('namespace') - } - - /** - * Parse non-block at-rules - */ - - function _atrule(name) { - var pos = position(); - var m = match(new RegExp('^@' + name + ' *([^;\\n]+);')); - if (!m) return; - var ret = { type: name }; - ret[name] = m[1].replace(/^\s+|\s+$/g, ''); - return pos(ret); - } - - /** - * Parse at rule. - */ - - function atrule() { - return atkeyframes() - || atmedia() - || atsupports() - || atimport() - || atcharset() - || atnamespace() - || atdocument() - || atpage(); - } - - /** - * Parse rule. - */ - - function rule() { - var pos = position(); - var sel = selector(); - - if (!sel) return; - comments(); - - return pos({ - type: 'rule', - selectors: sel, - declarations: declarations() - }); - } - - return stylesheet(); -}; - +module.exports = require('css').parse; diff --git a/package.json b/package.json index 2138af8..b9b243f 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,23 @@ { "name": "css-parse", - "version": "1.5.2", + "version": "2.0.0", "description": "CSS parser", - "keywords": ["css", "parser", "stylesheet"], + "main": "index", + "files": [ + "index.js" + ], + "dependencies": { + "css": "^2.0.0" + }, "author": "TJ Holowaychuk ", "license": "MIT", - "devDependencies": { - "mocha": "*", - "should": "*" + "repository": { + "type": "git", + "url": "https://github.com/reworkcss/css-parse.git" }, - "main": "index" + "keywords": [ + "css", + "parser", + "stylesheet" + ] } diff --git a/test/cases/charset.css b/test/cases/charset.css deleted file mode 100644 index 035601c..0000000 --- a/test/cases/charset.css +++ /dev/null @@ -1,2 +0,0 @@ -@charset "UTF-8"; /* Set the encoding of the style sheet to Unicode UTF-8*/ -@charset 'iso-8859-15'; /* Set the encoding of the style sheet to Latin-9 (Western European languages, with euro sign) */ diff --git a/test/cases/charset.json b/test/cases/charset.json deleted file mode 100644 index f7d72ab..0000000 --- a/test/cases/charset.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "charset", - "charset": "\"UTF-8\"", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 18 - } - } - }, - { - "type": "comment", - "comment": " Set the encoding of the style sheet to Unicode UTF-8", - "position": { - "start": { - "line": 1, - "column": 25 - }, - "end": { - "line": 1, - "column": 82 - } - } - }, - { - "type": "charset", - "charset": "'iso-8859-15'", - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 24 - } - } - }, - { - "type": "comment", - "comment": " Set the encoding of the style sheet to Latin-9 (Western European languages, with euro sign) ", - "position": { - "start": { - "line": 2, - "column": 25 - }, - "end": { - "line": 2, - "column": 122 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/comment.css b/test/cases/comment.css deleted file mode 100644 index 6fadbbb..0000000 --- a/test/cases/comment.css +++ /dev/null @@ -1,10 +0,0 @@ -/* 1 */ - -body { /* 2 */ - /* 3 */ - /**/foo: 'bar'; - /* 4 */ -} /* 5 */ - -/* 6 */ - diff --git a/test/cases/comment.json b/test/cases/comment.json deleted file mode 100644 index 5459552..0000000 --- a/test/cases/comment.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "comment", - "comment": " 1 ", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "comment", - "comment": " 2 ", - "position": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - { - "type": "comment", - "comment": " 3 ", - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 10 - } - } - }, - { - "type": "comment", - "comment": "", - "position": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 7 - } - } - }, - { - "type": "declaration", - "property": "foo", - "value": "'bar'", - "position": { - "start": { - "line": 5, - "column": 7 - }, - "end": { - "line": 5, - "column": 17 - } - } - }, - { - "type": "comment", - "comment": " 4 ", - "position": { - "start": { - "line": 6, - "column": 3 - }, - "end": { - "line": 6, - "column": 10 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 7, - "column": 2 - } - } - }, - { - "type": "comment", - "comment": " 5 ", - "position": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 7, - "column": 10 - } - } - }, - { - "type": "comment", - "comment": " 6 ", - "position": { - "start": { - "line": 9, - "column": 1 - }, - "end": { - "line": 9, - "column": 8 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/comment.url.css b/test/cases/comment.url.css deleted file mode 100644 index 6788a85..0000000 --- a/test/cases/comment.url.css +++ /dev/null @@ -1,7 +0,0 @@ -/* http://foo.com/bar/baz.html */ -/**/ - -foo { /*/*/ - /* something */ - bar: baz; /* http://foo.com/bar/baz.html */ -} diff --git a/test/cases/comment.url.json b/test/cases/comment.url.json deleted file mode 100644 index 12c6f46..0000000 --- a/test/cases/comment.url.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "comment", - "comment": " http://foo.com/bar/baz.html ", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 34 - } - } - }, - { - "type": "comment", - "comment": "", - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, - { - "type": "rule", - "selectors": [ - "foo" - ], - "declarations": [ - { - "type": "comment", - "comment": "/", - "position": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 12 - } - } - }, - { - "type": "comment", - "comment": " something ", - "position": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 18 - } - } - }, - { - "type": "declaration", - "property": "bar", - "value": "baz", - "position": { - "start": { - "line": 6, - "column": 3 - }, - "end": { - "line": 6, - "column": 11 - } - } - }, - { - "type": "comment", - "comment": " http://foo.com/bar/baz.html ", - "position": { - "start": { - "line": 6, - "column": 13 - }, - "end": { - "line": 6, - "column": 46 - } - } - } - ], - "position": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 7, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/document.css b/test/cases/document.css deleted file mode 100644 index 8c2cd86..0000000 --- a/test/cases/document.css +++ /dev/null @@ -1,7 +0,0 @@ -@-moz-document url-prefix() { - /* ui above */ - .ui-select .ui-btn select { - /* ui inside */ - opacity:.0001 - } -} diff --git a/test/cases/document.json b/test/cases/document.json deleted file mode 100644 index 55f6de1..0000000 --- a/test/cases/document.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "document", - "document": "url-prefix()", - "vendor": "-moz-", - "rules": [ - { - "type": "comment", - "comment": " ui above ", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 17 - } - } - }, - { - "type": "rule", - "selectors": [ - ".ui-select .ui-btn select" - ], - "declarations": [ - { - "type": "comment", - "comment": " ui inside ", - "position": { - "start": { - "line": 4, - "column": 5 - }, - "end": { - "line": 4, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "opacity", - "value": ".0001", - "position": { - "start": { - "line": 5, - "column": 5 - }, - "end": { - "line": 6, - "column": 3 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 6, - "column": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 7, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/empty.css b/test/cases/empty.css deleted file mode 100644 index e69de29..0000000 diff --git a/test/cases/empty.json b/test/cases/empty.json deleted file mode 100644 index 9a68693..0000000 --- a/test/cases/empty.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [] - } -} \ No newline at end of file diff --git a/test/cases/import.css b/test/cases/import.css deleted file mode 100644 index 3d9ad35..0000000 --- a/test/cases/import.css +++ /dev/null @@ -1,6 +0,0 @@ - -@import url("fineprint.css") print; -@import url("bluish.css") projection, tv; -@import 'custom.css'; -@import "common.css" screen, projection; -@import url('landscape.css') screen and (orientation:landscape); diff --git a/test/cases/import.json b/test/cases/import.json deleted file mode 100644 index eb520b6..0000000 --- a/test/cases/import.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "import", - "import": "url(\"fineprint.css\") print", - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 36 - } - } - }, - { - "type": "import", - "import": "url(\"bluish.css\") projection, tv", - "position": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 3, - "column": 42 - } - } - }, - { - "type": "import", - "import": "'custom.css'", - "position": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - { - "type": "import", - "import": "\"common.css\" screen, projection", - "position": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 5, - "column": 41 - } - } - }, - { - "type": "import", - "import": "url('landscape.css') screen and (orientation:landscape)", - "position": { - "start": { - "line": 6, - "column": 1 - }, - "end": { - "line": 6, - "column": 65 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/import.messed.css b/test/cases/import.messed.css deleted file mode 100644 index 6184cf6..0000000 --- a/test/cases/import.messed.css +++ /dev/null @@ -1,7 +0,0 @@ - - @import url("fineprint.css") print; - @import url("bluish.css") projection, tv; - @import 'custom.css'; - @import "common.css" screen, projection ; - - @import url('landscape.css') screen and (orientation:landscape); diff --git a/test/cases/import.messed.json b/test/cases/import.messed.json deleted file mode 100644 index 5c8a07c..0000000 --- a/test/cases/import.messed.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "import", - "import": "url(\"fineprint.css\") print", - "position": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 39 - } - } - }, - { - "type": "import", - "import": "url(\"bluish.css\") projection, tv", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 44 - } - } - }, - { - "type": "import", - "import": "'custom.css'", - "position": { - "start": { - "line": 4, - "column": 7 - }, - "end": { - "line": 4, - "column": 28 - } - } - }, - { - "type": "import", - "import": "\"common.css\" screen, projection", - "position": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 45 - } - } - }, - { - "type": "import", - "import": "url('landscape.css') screen and (orientation:landscape)", - "position": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 7, - "column": 67 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/invalid.css b/test/cases/invalid.css deleted file mode 100644 index cdd7a0f..0000000 --- a/test/cases/invalid.css +++ /dev/null @@ -1,3 +0,0 @@ -{ - - asdfasdfasdfasd \ No newline at end of file diff --git a/test/cases/invalid.json b/test/cases/invalid.json deleted file mode 100644 index 9a68693..0000000 --- a/test/cases/invalid.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [] - } -} \ No newline at end of file diff --git a/test/cases/keyframes.complex.css b/test/cases/keyframes.complex.css deleted file mode 100644 index 79eb689..0000000 --- a/test/cases/keyframes.complex.css +++ /dev/null @@ -1,8 +0,0 @@ -@keyframes foo { - 0% { top: 0; left: 0 } - 30.50% { top: 50px } - .68% , - 72% - , 85% { left: 50px } - 100% { top: 100px; left: 100% } -} \ No newline at end of file diff --git a/test/cases/keyframes.complex.json b/test/cases/keyframes.complex.json deleted file mode 100644 index b6035ca..0000000 --- a/test/cases/keyframes.complex.json +++ /dev/null @@ -1,187 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "keyframes", - "name": "foo", - "keyframes": [ - { - "type": "keyframe", - "values": [ - "0%" - ], - "declarations": [ - { - "type": "declaration", - "property": "top", - "value": "0", - "position": { - "start": { - "line": 2, - "column": 8 - }, - "end": { - "line": 2, - "column": 14 - } - } - }, - { - "type": "declaration", - "property": "left", - "value": "0", - "position": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 24 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 25 - } - } - }, - { - "type": "keyframe", - "values": [ - "30.50%" - ], - "declarations": [ - { - "type": "declaration", - "property": "top", - "value": "50px", - "position": { - "start": { - "line": 3, - "column": 12 - }, - "end": { - "line": 3, - "column": 22 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 23 - } - } - }, - { - "type": "keyframe", - "values": [ - ".68%", - "72%", - "85%" - ], - "declarations": [ - { - "type": "declaration", - "property": "left", - "value": "50px", - "position": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 6, - "column": 26 - } - } - } - ], - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 6, - "column": 27 - } - } - }, - { - "type": "keyframe", - "values": [ - "100%" - ], - "declarations": [ - { - "type": "declaration", - "property": "top", - "value": "100px", - "position": { - "start": { - "line": 7, - "column": 10 - }, - "end": { - "line": 7, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "left", - "value": "100%", - "position": { - "start": { - "line": 7, - "column": 22 - }, - "end": { - "line": 7, - "column": 33 - } - } - } - ], - "position": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 7, - "column": 34 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 8, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/keyframes.css b/test/cases/keyframes.css deleted file mode 100644 index 24f19ff..0000000 --- a/test/cases/keyframes.css +++ /dev/null @@ -1,13 +0,0 @@ -@keyframes fade { - /* from above */ - from { - /* from inside */ - opacity: 0; - } - - /* to above */ - to { - /* to inside */ - opacity: 1; - } -} \ No newline at end of file diff --git a/test/cases/keyframes.json b/test/cases/keyframes.json deleted file mode 100644 index 0694ce0..0000000 --- a/test/cases/keyframes.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "keyframes", - "name": "fade", - "keyframes": [ - { - "type": "comment", - "comment": " from above ", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 19 - } - } - }, - { - "type": "keyframe", - "values": [ - "from" - ], - "declarations": [ - { - "type": "comment", - "comment": " from inside ", - "position": { - "start": { - "line": 4, - "column": 5 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - { - "type": "declaration", - "property": "opacity", - "value": "0", - "position": { - "start": { - "line": 5, - "column": 5 - }, - "end": { - "line": 5, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 6, - "column": 4 - } - } - }, - { - "type": "comment", - "comment": " to above ", - "position": { - "start": { - "line": 8, - "column": 3 - }, - "end": { - "line": 8, - "column": 17 - } - } - }, - { - "type": "keyframe", - "values": [ - "to" - ], - "declarations": [ - { - "type": "comment", - "comment": " to inside ", - "position": { - "start": { - "line": 10, - "column": 5 - }, - "end": { - "line": 10, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "opacity", - "value": "1", - "position": { - "start": { - "line": 11, - "column": 5 - }, - "end": { - "line": 11, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 9, - "column": 3 - }, - "end": { - "line": 12, - "column": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 13, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/keyframes.messed.css b/test/cases/keyframes.messed.css deleted file mode 100644 index 32f0be9..0000000 --- a/test/cases/keyframes.messed.css +++ /dev/null @@ -1,6 +0,0 @@ -@keyframes fade {from - {opacity: 0; - } -to - { - opacity: 1;}} \ No newline at end of file diff --git a/test/cases/keyframes.messed.json b/test/cases/keyframes.messed.json deleted file mode 100644 index b322137..0000000 --- a/test/cases/keyframes.messed.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "keyframes", - "name": "fade", - "keyframes": [ - { - "type": "keyframe", - "values": [ - "from" - ], - "declarations": [ - { - "type": "declaration", - "property": "opacity", - "value": "0", - "position": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 14 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 3, - "column": 7 - } - } - }, - { - "type": "keyframe", - "values": [ - "to" - ], - "declarations": [ - { - "type": "declaration", - "property": "opacity", - "value": "1", - "position": { - "start": { - "line": 6, - "column": 6 - }, - "end": { - "line": 6, - "column": 16 - } - } - } - ], - "position": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 6, - "column": 18 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 6, - "column": 19 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/keyframes.vendor.css b/test/cases/keyframes.vendor.css deleted file mode 100644 index 54f15e1..0000000 --- a/test/cases/keyframes.vendor.css +++ /dev/null @@ -1,4 +0,0 @@ -@-webkit-keyframes fade { - from { opacity: 0 } - to { opacity: 1 } -} \ No newline at end of file diff --git a/test/cases/keyframes.vendor.json b/test/cases/keyframes.vendor.json deleted file mode 100644 index 66a0783..0000000 --- a/test/cases/keyframes.vendor.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "keyframes", - "name": "fade", - "vendor": "-webkit-", - "keyframes": [ - { - "type": "keyframe", - "values": [ - "from" - ], - "declarations": [ - { - "type": "declaration", - "property": "opacity", - "value": "0", - "position": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 21 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 22 - } - } - }, - { - "type": "keyframe", - "values": [ - "to" - ], - "declarations": [ - { - "type": "declaration", - "property": "opacity", - "value": "1", - "position": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 19 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 20 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 4, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/media.css b/test/cases/media.css deleted file mode 100644 index b9dc81e..0000000 --- a/test/cases/media.css +++ /dev/null @@ -1,26 +0,0 @@ -@media screen, projection { - /* html above */ - html { - /* html inside */ - background: #fffef0; - color: #300; - } - - /* body above */ - body { - /* body inside */ - max-width: 35em; - margin: 0 auto; - } -} - -@media print { - html { - background: #fff; - color: #000; - } - body { - padding: 1in; - border: 0.5pt solid #666; - } -} \ No newline at end of file diff --git a/test/cases/media.json b/test/cases/media.json deleted file mode 100644 index 9d9ae30..0000000 --- a/test/cases/media.json +++ /dev/null @@ -1,287 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "media", - "media": "screen, projection", - "rules": [ - { - "type": "comment", - "comment": " html above ", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 19 - } - } - }, - { - "type": "rule", - "selectors": [ - "html" - ], - "declarations": [ - { - "type": "comment", - "comment": " html inside ", - "position": { - "start": { - "line": 4, - "column": 5 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - { - "type": "declaration", - "property": "background", - "value": "#fffef0", - "position": { - "start": { - "line": 5, - "column": 5 - }, - "end": { - "line": 5, - "column": 24 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "#300", - "position": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 6, - "column": 16 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 7, - "column": 4 - } - } - }, - { - "type": "comment", - "comment": " body above ", - "position": { - "start": { - "line": 9, - "column": 3 - }, - "end": { - "line": 9, - "column": 19 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "comment", - "comment": " body inside ", - "position": { - "start": { - "line": 11, - "column": 5 - }, - "end": { - "line": 11, - "column": 22 - } - } - }, - { - "type": "declaration", - "property": "max-width", - "value": "35em", - "position": { - "start": { - "line": 12, - "column": 5 - }, - "end": { - "line": 12, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "margin", - "value": "0 auto", - "position": { - "start": { - "line": 13, - "column": 5 - }, - "end": { - "line": 13, - "column": 19 - } - } - } - ], - "position": { - "start": { - "line": 10, - "column": 3 - }, - "end": { - "line": 14, - "column": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 15, - "column": 2 - } - } - }, - { - "type": "media", - "media": "print", - "rules": [ - { - "type": "rule", - "selectors": [ - "html" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "#fff", - "position": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 21 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "#000", - "position": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 16 - } - } - } - ], - "position": { - "start": { - "line": 18, - "column": 3 - }, - "end": { - "line": 21, - "column": 4 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "padding", - "value": "1in", - "position": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 17 - } - } - }, - { - "type": "declaration", - "property": "border", - "value": "0.5pt solid #666", - "position": { - "start": { - "line": 24, - "column": 5 - }, - "end": { - "line": 24, - "column": 29 - } - } - } - ], - "position": { - "start": { - "line": 22, - "column": 3 - }, - "end": { - "line": 25, - "column": 4 - } - } - } - ], - "position": { - "start": { - "line": 17, - "column": 1 - }, - "end": { - "line": 26, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/media.messed.css b/test/cases/media.messed.css deleted file mode 100644 index 9b678f9..0000000 --- a/test/cases/media.messed.css +++ /dev/null @@ -1,27 +0,0 @@ -@media screen, projection{ html - - { -background: #fffef0; - color:#300; - } - body - -{ - max-width: 35em; - margin: 0 auto; - - -} - } - -@media print -{ - html { - background: #fff; - color: #000; - } - body { - padding: 1in; - border: 0.5pt solid #666; - } -} \ No newline at end of file diff --git a/test/cases/media.messed.json b/test/cases/media.messed.json deleted file mode 100644 index 3deaeb2..0000000 --- a/test/cases/media.messed.json +++ /dev/null @@ -1,231 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "media", - "media": "screen, projection", - "rules": [ - { - "type": "rule", - "selectors": [ - "html" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "#fffef0", - "position": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 4, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "#300", - "position": { - "start": { - "line": 5, - "column": 5 - }, - "end": { - "line": 5, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 28 - }, - "end": { - "line": 6, - "column": 4 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "max-width", - "value": "35em", - "position": { - "start": { - "line": 10, - "column": 5 - }, - "end": { - "line": 10, - "column": 20 - } - } - }, - { - "type": "declaration", - "property": "margin", - "value": "0 auto", - "position": { - "start": { - "line": 11, - "column": 5 - }, - "end": { - "line": 11, - "column": 19 - } - } - } - ], - "position": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 14, - "column": 2 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 15, - "column": 4 - } - } - }, - { - "type": "media", - "media": "print", - "rules": [ - { - "type": "rule", - "selectors": [ - "html" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "#fff", - "position": { - "start": { - "line": 20, - "column": 15 - }, - "end": { - "line": 20, - "column": 31 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "#000", - "position": { - "start": { - "line": 21, - "column": 15 - }, - "end": { - "line": 21, - "column": 26 - } - } - } - ], - "position": { - "start": { - "line": 19, - "column": 15 - }, - "end": { - "line": 22, - "column": 16 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "padding", - "value": "1in", - "position": { - "start": { - "line": 24, - "column": 15 - }, - "end": { - "line": 24, - "column": 27 - } - } - }, - { - "type": "declaration", - "property": "border", - "value": "0.5pt solid #666", - "position": { - "start": { - "line": 25, - "column": 15 - }, - "end": { - "line": 25, - "column": 39 - } - } - } - ], - "position": { - "start": { - "line": 23, - "column": 15 - }, - "end": { - "line": 26, - "column": 16 - } - } - } - ], - "position": { - "start": { - "line": 17, - "column": 1 - }, - "end": { - "line": 27, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/messed-up.css b/test/cases/messed-up.css deleted file mode 100644 index 96fcc4e..0000000 --- a/test/cases/messed-up.css +++ /dev/null @@ -1,15 +0,0 @@ -body { foo - : - 'bar' } - - body{foo:bar;bar:baz} - body - { - foo - : - bar - ; - bar - : - baz - } \ No newline at end of file diff --git a/test/cases/messed-up.json b/test/cases/messed-up.json deleted file mode 100644 index 53f7079..0000000 --- a/test/cases/messed-up.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "foo\n ", - "value": "'bar'", - "position": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 3, - "column": 9 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 3, - "column": 10 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "foo", - "value": "bar", - "position": { - "start": { - "line": 5, - "column": 9 - }, - "end": { - "line": 5, - "column": 16 - } - } - }, - { - "type": "declaration", - "property": "bar", - "value": "baz", - "position": { - "start": { - "line": 5, - "column": 17 - }, - "end": { - "line": 5, - "column": 24 - } - } - } - ], - "position": { - "start": { - "line": 5, - "column": 4 - }, - "end": { - "line": 5, - "column": 25 - } - } - }, - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "foo\n ", - "value": "bar", - "position": { - "start": { - "line": 8, - "column": 6 - }, - "end": { - "line": 11, - "column": 6 - } - } - }, - { - "type": "declaration", - "property": "bar\n ", - "value": "baz", - "position": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 15, - "column": 6 - } - } - } - ], - "position": { - "start": { - "line": 6, - "column": 4 - }, - "end": { - "line": 15, - "column": 7 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/namespace.css b/test/cases/namespace.css deleted file mode 100644 index 6982d5e..0000000 --- a/test/cases/namespace.css +++ /dev/null @@ -1,2 +0,0 @@ -@namespace "http://www.w3.org/1999/xhtml"; -@namespace svg "http://www.w3.org/2000/svg"; \ No newline at end of file diff --git a/test/cases/namespace.json b/test/cases/namespace.json deleted file mode 100644 index 49565b1..0000000 --- a/test/cases/namespace.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "namespace", - "namespace": "\"http://www.w3.org/1999/xhtml\"", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 43 - } - } - }, - { - "type": "namespace", - "namespace": "svg \"http://www.w3.org/2000/svg\"", - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 2, - "column": 45 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/no-semi.css b/test/cases/no-semi.css deleted file mode 100644 index 652cdf2..0000000 --- a/test/cases/no-semi.css +++ /dev/null @@ -1,5 +0,0 @@ - -tobi loki jane { - are: 'all'; - the-species: called "ferrets" -} diff --git a/test/cases/no-semi.json b/test/cases/no-semi.json deleted file mode 100644 index dd7c80f..0000000 --- a/test/cases/no-semi.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "tobi loki jane" - ], - "declarations": [ - { - "type": "declaration", - "property": "are", - "value": "'all'", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 13 - } - } - }, - { - "type": "declaration", - "property": "the-species", - "value": "called \"ferrets\"", - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 5, - "column": 1 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 5, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/paged-media.css b/test/cases/paged-media.css deleted file mode 100644 index 8e9338e..0000000 --- a/test/cases/paged-media.css +++ /dev/null @@ -1,9 +0,0 @@ -/* toc above */ -@page toc, index:blank { - /* toc inside */ - color: green; -} - -@page { - font-size: 16pt; -} diff --git a/test/cases/paged-media.json b/test/cases/paged-media.json deleted file mode 100644 index 6272900..0000000 --- a/test/cases/paged-media.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "comment", - "comment": " toc above ", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 16 - } - } - }, - { - "type": "page", - "selectors": [ - "toc", - "index:blank" - ], - "declarations": [ - { - "type": "comment", - "comment": " toc inside ", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 19 - } - } - }, - { - "type": "declaration", - "property": "color", - "value": "green", - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 5, - "column": 2 - } - } - }, - { - "type": "page", - "selectors": [], - "declarations": [ - { - "type": "declaration", - "property": "font-size", - "value": "16pt", - "position": { - "start": { - "line": 8, - "column": 3 - }, - "end": { - "line": 8, - "column": 18 - } - } - } - ], - "position": { - "start": { - "line": 7, - "column": 1 - }, - "end": { - "line": 9, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/props.css b/test/cases/props.css deleted file mode 100644 index 6549151..0000000 --- a/test/cases/props.css +++ /dev/null @@ -1,6 +0,0 @@ - -tobi loki jane { - are: 'all'; - the-species: called "ferrets"; - *even: 'ie crap'; -} diff --git a/test/cases/props.json b/test/cases/props.json deleted file mode 100644 index 0c355b5..0000000 --- a/test/cases/props.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "tobi loki jane" - ], - "declarations": [ - { - "type": "declaration", - "property": "are", - "value": "'all'", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 13 - } - } - }, - { - "type": "declaration", - "property": "the-species", - "value": "called \"ferrets\"", - "position": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 32 - } - } - }, - { - "type": "declaration", - "property": "*even", - "value": "'ie crap'", - "position": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 19 - } - } - } - ], - "position": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/quoted.css b/test/cases/quoted.css deleted file mode 100644 index 373340e..0000000 --- a/test/cases/quoted.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background: url('some;stuff;here') 50% 50% no-repeat; -} \ No newline at end of file diff --git a/test/cases/quoted.json b/test/cases/quoted.json deleted file mode 100644 index 770b858..0000000 --- a/test/cases/quoted.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "body" - ], - "declarations": [ - { - "type": "declaration", - "property": "background", - "value": "url('some;stuff;here') 50% 50% no-repeat", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 55 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/rule.css b/test/cases/rule.css deleted file mode 100644 index 84f5ffd..0000000 --- a/test/cases/rule.css +++ /dev/null @@ -1,3 +0,0 @@ -foo { - bar: 'baz'; -} \ No newline at end of file diff --git a/test/cases/rule.json b/test/cases/rule.json deleted file mode 100644 index 9892baf..0000000 --- a/test/cases/rule.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "foo" - ], - "declarations": [ - { - "type": "declaration", - "property": "bar", - "value": "'baz'", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 13 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/rules.css b/test/cases/rules.css deleted file mode 100644 index 329002e..0000000 --- a/test/cases/rules.css +++ /dev/null @@ -1,6 +0,0 @@ -tobi { - name: 'tobi'; -} -loki { - name: 'loki'; -} \ No newline at end of file diff --git a/test/cases/rules.json b/test/cases/rules.json deleted file mode 100644 index a5d651f..0000000 --- a/test/cases/rules.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - "tobi" - ], - "declarations": [ - { - "type": "declaration", - "property": "name", - "value": "'tobi'", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 3, - "column": 2 - } - } - }, - { - "type": "rule", - "selectors": [ - "loki" - ], - "declarations": [ - { - "type": "declaration", - "property": "name", - "value": "'loki'", - "position": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 15 - } - } - } - ], - "position": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/supports.css b/test/cases/supports.css deleted file mode 100644 index 4ca696a..0000000 --- a/test/cases/supports.css +++ /dev/null @@ -1,8 +0,0 @@ -@supports (display: flex) or (display: box) { - /* flex above */ - .flex { - /* flex inside */ - display: box; - display: flex; - } -} \ No newline at end of file diff --git a/test/cases/supports.json b/test/cases/supports.json deleted file mode 100644 index 67cb88c..0000000 --- a/test/cases/supports.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "supports", - "supports": "(display: flex) or (display: box)", - "rules": [ - { - "type": "comment", - "comment": " flex above ", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 19 - } - } - }, - { - "type": "rule", - "selectors": [ - ".flex" - ], - "declarations": [ - { - "type": "comment", - "comment": " flex inside ", - "position": { - "start": { - "line": 4, - "column": 5 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - { - "type": "declaration", - "property": "display", - "value": "box", - "position": { - "start": { - "line": 5, - "column": 5 - }, - "end": { - "line": 5, - "column": 17 - } - } - }, - { - "type": "declaration", - "property": "display", - "value": "flex", - "position": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 6, - "column": 18 - } - } - } - ], - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 7, - "column": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 8, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/cases/wtf.css b/test/cases/wtf.css deleted file mode 100644 index 62e28c4..0000000 --- a/test/cases/wtf.css +++ /dev/null @@ -1,4 +0,0 @@ -.wtf { - *overflow-x: hidden; - //max-height: 110px; -} \ No newline at end of file diff --git a/test/cases/wtf.json b/test/cases/wtf.json deleted file mode 100644 index e2d3cb5..0000000 --- a/test/cases/wtf.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "type": "stylesheet", - "stylesheet": { - "rules": [ - { - "type": "rule", - "selectors": [ - ".wtf" - ], - "declarations": [ - { - "type": "declaration", - "property": "*overflow-x", - "value": "hidden", - "position": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 22 - } - } - }, - { - "type": "declaration", - "property": "//max-height", - "value": "110px", - "position": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 22 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 4, - "column": 2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/test/css-parse.js b/test/css-parse.js deleted file mode 100644 index c6e6127..0000000 --- a/test/css-parse.js +++ /dev/null @@ -1,24 +0,0 @@ - -/** - * Module dependencies. - */ - -var parse = require('..') - , fs = require('fs') - , path = require('path') - , read = fs.readFileSync - , readdir = fs.readdirSync; - -describe('parse(str)', function(){ - readdir('test/cases').forEach(function(file){ - if (~file.indexOf('json')) return; - file = path.basename(file, '.css'); - it('should parse ' + file, function(){ - var css = read(path.join('test', 'cases', file + '.css'), 'utf8'); - var json = read(path.join('test', 'cases', file + '.json'), 'utf8'); - var ret = parse(css, { position: true }); - ret = JSON.stringify(ret, null, 2); - ret.should.equal(json); - }) - }); -})