parse method

  1. @nonVirtual
MetaInfo parse(
  1. Element htmlHead
)

Resolve rich information metadata from given htmlHead which is <head> Element in HTML.

This method should not be override. Instead, all data apply must be done under resolveMetaTags.

Implementation

@nonVirtual
MetaInfo parse(Element htmlHead) {
  final MetaInfoParser metaParser = MetaInfoParser()..markInitalized();
  final Iterable<PropertyPair> metaTagsProp = htmlHead
      .querySelectorAll(
          r'meta[property^="' + propertyNamePrefix + r':"][content]')
      .map((e) {
    final attr = e.attributes;

    String ctx = attr['content']!;

    try {
      ctx = utf8.decode(ctx.runes.toList());
    } on FormatException {
      // If not work, leave origin ctx.
    }

    return (attr['property']!, ctx);
  });

  resolveMetaTags(metaParser, UnmodifiableListView(metaTagsProp));

  return metaParser.compile();
}