scopify 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 59

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 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:scopify/scopify.dart';
  
Version Uploaded Documentation Archive
0.2.2 Sep 10, 2018 Go to the documentation of scopify 0.2.2 Download scopify 0.2.2 archive
0.2.1 Jul 3, 2018 Go to the documentation of scopify 0.2.1 Download scopify 0.2.1 archive
0.2.0 Dec 16, 2017 Go to the documentation of scopify 0.2.0 Download scopify 0.2.0 archive
0.1.0 Sep 26, 2017 Go to the documentation of scopify 0.1.0 Download scopify 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/scopify.dart.

Run dartfmt to format lib/scopify.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use scopify.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
csslib ^0.14.4 0.14.6
html ^0.13.3 0.13.3+3
meta ^1.1.5 1.1.6
source_span ^1.4.0 1.4.1
uuid ^1.0.0 1.0.3
Transitive dependencies
args 1.5.1
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
logging 0.11.3+2
path 1.6.2
typed_data 1.1.6
utf 0.9.0+5
Dev dependencies
test any