htmlwhitelist 0.4.1 copy "htmlwhitelist: ^0.4.1" to clipboard
htmlwhitelist: ^0.4.1 copied to clipboard

outdatedDart 1 only

This library can be used to clean up html on the server.

Html Whitelist #

Build Status

Introduction #

This library can be used to whitelist html elements, attributes and attribute values.

Usage #

import 'package:htmlwhitelist/htmlwhitelist.dart';

main() {
  var contents = '<b>See:</b> <a href="docs.html">the documentation</a>';
  var safe = Whitelist.simpleText.safeCopy(contents);
  print(safe);
}

prints

<b>See:</b> the documentation

If you have a DocumentFragment instead of a String you can use the Cleaner instead:

import 'package:htmlwhitelist/htmlwhitelist.dart';
import 'package:html/parser.dart';
import 'package:html/dom.dart';

main() {
  var contents = '<b>See:</b> <a href="docs.html">the documentation</a>';

  DocumentFragment fragment = parseFragment(contents);
  DocumentFragment safeCopy = Whitelist.simpleText.cleaner.safeCopy(fragment);

  print(safeCopy.outerHtml);
}

prints

<b>See:</b> the documentation

License and contributors #

0
likes
0
pub points
70%
popularity

Publisher

unverified uploader

This library can be used to clean up html on the server.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

html

More

Packages that depend on htmlwhitelist