The Webfeed Flutter package for Appeto SDK.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 regels
798 B

  1. import 'package:xml/xml/nodes/element.dart';
  2. final _imagesRegExp = new RegExp(
  3. "<img\\s.*?src=(?:'|\")([^'\">]+)(?:'|\")",
  4. multiLine: true,
  5. caseSensitive: false,
  6. );
  7. /// For RSS Content Module:
  8. ///
  9. /// - `xmlns:content="http://purl.org/rss/1.0/modules/content/"`
  10. ///
  11. class RssContent {
  12. String value;
  13. Iterable<String> images;
  14. RssContent(this.value, this.images);
  15. factory RssContent.parse(XmlElement element) {
  16. if (element == null) {
  17. return null;
  18. }
  19. final content = element.text;
  20. final images = <String>[];
  21. _imagesRegExp.allMatches(content).forEach((match) {
  22. images.add(match.group(1));
  23. });
  24. return new RssContent(content, images);
  25. }
  26. @override
  27. String toString() {
  28. return '''
  29. content: $value
  30. images: $images
  31. ''';
  32. }
  33. }