scopify 0.2.2

  • Readme
  • Changelog
  • Installing
  • 43

scopify #

scopify implements scoped styling in a manner similar to HTML5 and Vue. It processes the given HTML nodes and CSS stylesheets in-place, adding specialized attributes that make sure the CSS can only ever modify the given HTML.

Example #

import 'package:csslib/parser.dart' as css;
import 'package:csslib/visitor.dart' show CssPrinter;
import 'package:html/parser.dart' as html;

import 'package:scopify/scopify.dart';

void main() {
  var myCss = 'p#my-id { color: purple; }';
  var myHtml = '<p id="my-id">purplified text here</p>';

  // First, we have to parse the CSS and HTMl text.
  var style = css.parse(myCss);
  var node = html.parse(myHtml);

  // Now, we can call scopify. It takes two arguments: a list of HTML nodes, and a list of CSS
  // stylesheets to process.
  scopify(html: [node], css: [style]);

  // The HTML and CSS parse trees were modified in-place. Now, the CSS will only ever modify this
  // HTML code, even when combined with other HTML code.

  // To get the resulting HTML:
  var resultHtml = node.outerHtml;

  // and CSS:
  var printer = new CssPrinter();
  var resultCss = printer.toString();

development #

0.2.0 #

Scoped styles have been changed now will not automatically "bleed" into other scoped styles. Bleeding can still be manually enabled, but it will still not bleed into other styles managed by scopify, e.g. it is more restrictive.

0.1.0 #

Initial version.

Use this package as a library

1. Depend on it

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

  scopify: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:scopify/scopify.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/scopify.dart. (-5.36 points)

Analysis of lib/scopify.dart reported 11 hints, including:

line 19 col 5: Unnecessary new keyword.

line 20 col 7: Unnecessary new keyword.

line 28 col 21: Unnecessary new keyword.

line 32 col 22: Unnecessary new keyword.

line 37 col 19: Unnecessary new keyword.

Maintenance issues and suggestions

Support latest dependencies. (-30 points)

The version constraint in pubspec.yaml does not support the latest published versions for 3 dependencies (csslib, html, uuid).

Package is getting outdated. (-37.81 points)

The package was last published 71 weeks ago.

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. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

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

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
csslib ^0.14.4 0.14.6+1 0.16.1
html ^0.13.3 0.13.4+2 0.14.0+3
meta ^1.1.5 1.1.8
source_span ^1.4.0 1.6.0
uuid ^1.0.0 1.0.3 2.0.4
Transitive dependencies
args 1.5.2
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
logging 0.11.4
path 1.6.4
term_glyph 1.1.0
typed_data 1.1.6
utf 0.9.0+5
Dev dependencies
test any