function renderer()

in packages/postsvg/lib/renderer.js [26:47]


function renderer(tree, options = {}) {
  const opts = merge(defaultOptions, options);

  /**
   * Workaround for https://github.com/fb55/htmlparser2/issues/187
   * Also see https://github.com/fb55/htmlparser2/pull/129
   */
  opts.singleTags = opts.singleTags.filter((tag) => {
    let hasContent = false;

    api.match.call(tree, { tag }, (node) => {
      if (typeof node.content !== 'undefined' && !hasContent) {
        hasContent = true;
      }
      return node;
    });

    return !hasContent;
  });

  return posthtmlRenderer(tree, opts);
}