docs: function extract(buf, tags) {
    if (typeof buf !== 'string') {
      throw new TypeError('First argument must be a string.');
    }
    if (!Array.isArray(tags)) {
      throw new TypeError('Second argument must be an array.');
    }
  
    let isRootTagFinded = {};
    let tagsCounter = {};
  
    let parser = new htmlparser.Parser({
      onopentag(tag, attrs) {
        if (tags.indexOf(tag) === -1) return;
  
        if (isRootTagFinded[tag]) {
          tagsCounter[tag] += 1;
  
          return;
        }
  
        isRootTagFinded[tag] = true;
        tagsCounter[tag] = 1;
  
        section = {tag, attrs};
        sectStart = parser.endIndex + 1;
      },
      onclosetag(tag) {
        if (tags.indexOf(tag) === -1) return;
  
        if (--tagsCounter[tag]) {
          return;
        }
  
        section.tag = tag;
        section.text = buf.substring(sectStart, parser.startIndex);
        section.offset = has(section.attrs, 'src') ? 0 : loc.getLine(sectStart);
  
        sections.push(section);
      },
      onerror(err) {
        /* istanbul ignore next */
        throw err;
      },
    }, {decodeEntities: true});
  
    // for now htmlparser2 doesn't provides line numbers for tag
    // @see https://github.com/fb55/htmlparser2/issues/89
    let loc = new Location(buf);
    let sectStart = 0;
    let section = {};
  
    let sections = [];
  
    parser.parseComplete(buf);
  
    return sections;
  }