buildMetaInfo method

  1. @visibleForTesting
MetaInfo buildMetaInfo(
  1. Document htmlDocument
)

Construct MetaInfo with given Document.

If <meta> Element's property prefix hasBeenRegistered, it refers to the first matched prefix given from an order of Document and apply all available fields in MetaInfo. Otherwise, it will return MetaInfo with all empty field when it cannot be able to find matched prefix.

Update in 1.1.1: This method no longer available for non testing purpose.

Implementation

@visibleForTesting
MetaInfo buildMetaInfo(Document htmlDocument) {
  MetaInfo parsedResult = MetaInfo();

  for (String prefix in _prefixSequence(htmlDocument)) {
    try {
      var parser = _findCorrespondedParser(prefix);
      parsedResult = parser.parse(htmlDocument.head!);
      break;
    } on StateError {
      // If the prefix does not supported.
      continue;
    }
  }

  return parsedResult;
}