OLD | NEW |
(Empty) | |
| 1 csslib in Pure Dart |
| 2 =================== |
| 3 |
| 4 This is a pure [Dart][dart] [CSS parser][cssparse]. Since it's 100% |
| 5 Dart you can use it safely from a script or server side app. |
| 6 |
| 7 Installation |
| 8 ------------ |
| 9 |
| 10 Add this to your `pubspec.yaml` (or create it): |
| 11 ```yaml |
| 12 dependencies: |
| 13 csslib: any |
| 14 ``` |
| 15 Then run the [Pub Package Manager][pub] (comes with the Dart SDK): |
| 16 |
| 17 pub install |
| 18 |
| 19 Usage |
| 20 ----- |
| 21 |
| 22 Parsing CSS is easy! |
| 23 ```dart |
| 24 import 'package:csslib/parser.dart' show parse; |
| 25 import 'package:csslib/css.dart'; |
| 26 |
| 27 main() { |
| 28 var stylesheet = parse( |
| 29 '.foo { color: red; left: 20px; top: 20px; width: 100px; height:200px }'); |
| 30 print(stylesheet.toString()); |
| 31 } |
| 32 ``` |
| 33 |
| 34 You can pass a String or list of bytes to `parse`. |
| 35 |
| 36 |
| 37 Updating |
| 38 -------- |
| 39 |
| 40 You can upgrade the library with: |
| 41 |
| 42 pub update |
| 43 |
| 44 Disclaimer: the APIs are not finished. Updating may break your code. If that |
| 45 happens, you can check the |
| 46 [commit log](https://github.com/dart-lang/csslib/commits/master), to figure |
| 47 out what the change was. |
| 48 |
| 49 If you want to avoid breakage, you can also put the version constraint in your |
| 50 `pubspec.yaml` in place of the word `any`. |
| 51 |
| 52 Running Tests |
| 53 ------------- |
| 54 |
| 55 All tests (both canary and suite) should be passing. Canary are quick test |
| 56 verifies that basic CSS is working. The suite tests are a comprehensive set of |
| 57 ~11,000 tests. |
| 58 |
| 59 ```bash |
| 60 export DART_SDK=path/to/dart/sdk |
| 61 |
| 62 # Make sure dependencies are installed |
| 63 pub install |
| 64 |
| 65 # Run command both canary and the suite tests |
| 66 test/run.sh |
| 67 ``` |
| 68 |
| 69 Run only the canary test: |
| 70 |
| 71 ```bash |
| 72 test/run.sh canary |
| 73 ``` |
| 74 |
| 75 Run only the suite tests: |
| 76 |
| 77 ```bash |
| 78 test/run.sh suite |
| 79 ``` |
| 80 |
| 81 [dart]: http://www.dartlang.org/ |
| 82 [pub]: http://www.dartlang.org/docs/pub-package-manager/ |
OLD | NEW |