scopify 0.2.2

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;
  print(resultHtml);

  // and CSS:
  var printer = new CssPrinter();
  style.visit(printer);
  var resultCss = printer.toString();
  print(resultCss);
}

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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
34
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
38
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

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

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:scopify/scopify.dart.

Health suggestions

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

Analysis of lib/scopify.dart reported 1 hint:

line 75 col 15: Don't explicitly initialize variables to null.

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).

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/README.md.

For more information see the pub package layout conventions.

Package is getting outdated. (-1.64 points)

The package was last published 53 weeks ago.

Dependencies

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+2
meta ^1.1.5 1.1.7
source_span ^1.4.0 1.5.5
uuid ^1.0.0 1.0.3 2.0.2
Transitive dependencies
args 1.5.2
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
logging 0.11.3+2
path 1.6.4
term_glyph 1.1.0
typed_data 1.1.6
utf 0.9.0+5
Dev dependencies
test any