csslib 0.14.6

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 86

CSS parser library for Dart #

This is a CSS parser written entirely in Dart. It can be used in the client/server/command line.

This package is installed with Pub, see: install instructions for this package.

Usage #

Parsing CSS is easy!

import 'package:csslib/parser.dart';

main() {
  var stylesheet = parse(
      '.foo { color: red; left: 20px; top: 20px; width: 100px; height:200px }');
  print(stylesheet.toDebugString());
}

You can pass a String or list of bytes to parse.

Running Tests #

Basic tests can be found in this repository:

pub run test

The full CSS test suite can be found in https://github.com/dart-lang/csslib-test-suite

cd ../csslib-test-suite
./run.sh

0.14.6 #

  • Removed whitespace between comma-delimited expressions in compact output.

    Before:

    div{color:rgba(0, 0, 0, 0.5);}
    

    After:

    div{color:rgba(0,0,0,0.5);}
    
  • Removed last semicolon from declaration groups in compact output.

    Before:

    div{color:red;background:blue;}
    

    After:

    div{color:red;background:blue}
    

0.14.5 #

  • Fixed a crashed caused by parsing :host() without an argument and added an error message explaining that a selector argument is expected.

0.14.4+1 #

  • Set max SDK version to <3.0.0, and adjust other dependencies.

0.14.4 #

  • Reduced whitespace in compact output for the @page at-rule and margin boxes.
  • Updated SDK version to 2.0.0-dev.17.0.
  • Stop using deprecated constants.

0.14.3 #

  • Reduced the amount of whitespace in compact output around braces.

0.14.2 #

  • Fixed Dart 2 runtime failure.

0.14.1 #

  • Deprecated package:csslib/css.dart. Use parser.dart and visitor.dart instead.

0.14.0 #

New features #

  • Supports nested at-rules.
  • Supports nested HTML comments in CSS comments and vice-versa.

Breaking changes #

  • The List<RuleSet> rulesets field on MediaDirective, HostDirective, and StyletDirective has been replaced by List<TreeNode> rules to allow nested at-rules in addition to rulesets.

0.13.6 #

  • Adds support for @viewport.
  • Adds support for -webkit-calc() and -moz-calc().
  • Adds support for querying media features without specifying an expression. For example: @media (transform-3d) { ... }.
  • Prevents exception being thrown for invalid dimension terms, and instead issues an error.

0.13.5 #

  • Adds support for @-moz-document.
  • Adds support for @supports.

0.13.4 #

  • Parses CSS 2.1 pseudo-elements as pseudo-elements instead of pseudo-classes.
  • Supports signed decimal numbers with no integer part.
  • Fixes parsing hexadecimal numbers when followed by an identifier.
  • Fixes parsing strings which contain unicode-range character sequences.

0.13.3+1 #

  • Fixes analyzer error.

0.13.3 #

  • Adds support for shadow host selectors :host() and :host-context().
  • Adds support for shadow-piercing descendant combinator >>> and its alias /deep/ for backwards compatibility.
  • Adds support for non-functional IE filter properties (i.e. filter: FlipH).
  • Fixes emitted CSS for @page directive when body includes declarations and page-margin boxes.
  • Exports Message from parser.dart so it's no longer necessary to import src/messages.dart to use the parser API.

0.13.2+2 #

  • Fix static warnings.

0.13.2+1 #

  • Fix new strong mode error.

0.13.2 #

  • Relax type of TreeNode.visit, to allow returning values from visitors.

0.13.1 #

  • Fix two checked mode bugs introduced in 0.13.0.

0.13.0 #

  • BREAKING Fix all strong mode errors and warnings. This involved adding more precise on some public APIs, which is why it may break users.

0.12.2 #

  • Fix to handle calc functions however, the expressions are treated as a LiteralTerm and not fully parsed into the AST.

0.12.1 #

  • Fix to handling of escapes in strings.

0.12.0+1 #

  • Allow the lastest version of logging package.

0.12.0 #

  • Top-level methods in parser.dart now take PreprocessorOptions instead of List<String>.

  • PreprocessorOptions.inputFile is now final.

0.11.0+4 #

  • Cleanup some ambiguous and some incorrect type signatures.

0.11.0+3 #

  • Improve the speed and memory efficiency of parsing.

0.11.0+2 #

  • Fix another test that was failing on IE10.

0.11.0+1 #

  • Fix a test that was failing on IE10.

0.11.0 #

  • Switch from source_maps' Span class to source_span's SourceSpan class.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  csslib: ^0.14.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:csslib/css.dart';
import 'package:csslib/parser.dart';
import 'package:csslib/visitor.dart';
  
Version Uploaded Documentation Archive
0.14.6 Oct 4, 2018 Go to the documentation of csslib 0.14.6 Download csslib 0.14.6 archive
0.14.5 Aug 14, 2018 Go to the documentation of csslib 0.14.5 Download csslib 0.14.5 archive
0.14.4+1 Jul 16, 2018 Go to the documentation of csslib 0.14.4+1 Download csslib 0.14.4+1 archive
0.14.4 May 10, 2018 Go to the documentation of csslib 0.14.4 Download csslib 0.14.4 archive
0.14.3 May 10, 2018 Go to the documentation of csslib 0.14.3 Download csslib 0.14.3 archive
0.14.2 May 1, 2018 Go to the documentation of csslib 0.14.2 Download csslib 0.14.2 archive
0.14.1 Sep 21, 2017 Go to the documentation of csslib 0.14.1 Download csslib 0.14.1 archive
0.14.0 May 30, 2017 Go to the documentation of csslib 0.14.0 Download csslib 0.14.0 archive
0.13.7+1 May 22, 2017 Go to the documentation of csslib 0.13.7+1 Download csslib 0.13.7+1 archive
0.13.7 May 22, 2017 Go to the documentation of csslib 0.13.7 Download csslib 0.13.7 archive

All 105 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
95
Health:
Code health derived from static analysis. [more]
76
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Health suggestions

Fix lib/parser.dart. (-10.89 points)

Analysis of lib/parser.dart reported 23 hints, including:

line 60 col 16: Use = to separate a named parameter from its default value.

line 61 col 18: Use = to separate a named parameter from its default value.

line 62 col 5: Don't explicitly initialize variables to null.

line 62 col 30: Use = to separate a named parameter from its default value.

line 174 col 50: Use = to separate a named parameter from its default value.

Fix lib/src/options.dart. (-3.93 points)

Analysis of lib/src/options.dart reported 8 hints, including:

line 42 col 20: Use = to separate a named parameter from its default value.

line 43 col 19: Use = to separate a named parameter from its default value.

line 44 col 23: Use = to separate a named parameter from its default value.

line 45 col 28: Use = to separate a named parameter from its default value.

line 46 col 25: Use = to separate a named parameter from its default value.

Fix lib/src/tree.dart. (-2.96 points)

Analysis of lib/src/tree.dart reported 6 hints, including:

line 306 col 21: Use = to separate a named parameter from its default value.

line 695 col 42: Use isNotEmpty instead of length

line 696 col 52: Use isNotEmpty instead of length

line 805 col 24: Use isNotEmpty instead of length

line 925 col 17: Use = to separate a named parameter from its default value.

Fix additional 9 files with analysis or formatting issues. (-8.49 points)

Additional issues in the following files:

  • lib/src/css_printer.dart (3 hints)
  • lib/css.dart (2 hints)
  • lib/src/analyzer.dart (2 hints)
  • lib/src/messages.dart (2 hints)
  • lib/src/polyfill.dart (2 hints)
  • lib/src/property.dart (2 hints)
  • lib/src/tokenizer.dart (2 hints)
  • bin/css.dart (1 hint)
  • lib/src/tokenizer_base.dart (1 hint)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and csslib.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.17.0 <3.0.0
args ^1.4.3 1.5.1
logging ^0.11.3 0.11.3+2
path ^1.6.1 1.6.2
source_span ^1.4.0 1.5.4
Transitive dependencies
charcode 1.1.2
term_glyph 1.1.0
Dev dependencies
test ^1.2.0