How to use htmlparser2-without-node-native - 8 common examples

To help you get started, we’ve selected a few htmlparser2-without-node-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phodal / growth / src / lib / htmlParse.js View on Github external
// var startTime = new Date().getTime()

  const rootStack = [{
    name: 'div',
    type: 'block',
  }];
  const tagStack = [rootStack[0]];

  const opts = {
    recognizeSelfClosing: true,
    lowerCaseAttributeNames: true,
    lowerCaseTags: true,
    decodeEntities: true,
  };

  const parser = new htmlparser.Parser({
    onopentag: (tag, attrs) => {
      // console.log('openTag:');
      // console.log(name);

      const father = tagStack[tagStack.length - 1];
      if (!father.children) {
        father.children = [];
      }

      if (indexOf(tag, blockTagArr)) {
        father.children.push({
          name: tag,
          attribs: attrs,
          type: 'block',
          parent: father,
        });
github smallpath / psnine / psnine / component / HTMLView / htmlToElement.tsx View on Github external
// console.log('???', parent && parent.attribs && parent.attribs.href, parent && parent.name, '====>')
          return (
            
          )
        }
      }
    })
  }

  const handler = new htmlparser.DomHandler(function (err, dom) {
    if (err) done(err)
    done(null, domToElement(dom, null, !opts.shouldForceInline))
  })
  const parser = new htmlparser.Parser(handler)
  parser.write(rawHtml)
  parser.done()
}
github smallpath / psnine / psnine / component / HTMLView / htmlToElement.tsx View on Github external
)
        } else {
          log('渲染Text组件', inInsideView, node.name, depth)
          let inlineNode = renderInlineNode(index, [], inInsideView)
          // console.log('???', parent && parent.attribs && parent.attribs.href, parent && parent.name, '====>')
          return (
            
          )
        }
      }
    })
  }

  const handler = new htmlparser.DomHandler(function (err, dom) {
    if (err) done(err)
    done(null, domToElement(dom, null, !opts.shouldForceInline))
  })
  const parser = new htmlparser.Parser(handler)
  parser.write(rawHtml)
  parser.done()
}
github smartkarma / react-native-jumbo-html / src / utils / parse-html.js View on Github external
export default function parseHTML(content: string): HTMLNode {
  const root: HTMLNode = new HTMLNode("div", {});

  let last = root;

  const html = new HTMLParser.Parser(
    {
      onopentag(name, attrs) {
        const node = new HTMLNode(name, attrs);
        last.append(node);
        last = node;
      },

      ontext(text) {
        if (!/^\s*$/.test(text)) {
          last.append(text);
        }
      },

      onclosetag() {
        last = last.parentNode;
      }
github hummingbird-me / kitsu-mobile / src / components / htmlView / htmlToElement.js View on Github external
{linebreakBefore}
            {listItemPrefix}
            {domToElement(node.children, node)}
            {linebreakAfter}
          
        );
      }
    });
  }

  const handler = new htmlparser.DomHandler((err, dom) => {
    if (err) done(err);
    done(null, domToElement(dom));
  });
  const parser = new htmlparser.Parser(handler);
  parser.write(rawHtml);
  parser.done();
}
github jsdf / react-native-htmlview / htmlToElement.js View on Github external
>
            {linebreakBefore}
            {listItemPrefix}
            {domToElement(node.children, node)}
            {linebreakAfter}
          
        );
      }
    });
  }

  const handler = new htmlparser.DomHandler(function(err, dom) {
    if (err) done(err);
    done(null, domToElement(dom));
  });
  const parser = new htmlparser.Parser(handler);
  parser.write(rawHtml);
  parser.done();
}
github hummingbird-me / kitsu-mobile / src / components / htmlView / htmlToElement.js View on Github external
const { NodeComponent } = opts;

        return (
          
            {linebreakBefore}
            {listItemPrefix}
            {domToElement(node.children, node)}
            {linebreakAfter}
          
        );
      }
    });
  }

  const handler = new htmlparser.DomHandler((err, dom) => {
    if (err) done(err);
    done(null, domToElement(dom));
  });
  const parser = new htmlparser.Parser(handler);
  parser.write(rawHtml);
  parser.done();
}
github jsdf / react-native-htmlview / htmlToElement.js View on Github external
key={index}
            onPress={linkPressHandler}
            style={!node.parent ? styles[node.name] : null}
            onLongPress={linkLongPressHandler}
          >
            {linebreakBefore}
            {listItemPrefix}
            {domToElement(node.children, node)}
            {linebreakAfter}
          
        );
      }
    });
  }

  const handler = new htmlparser.DomHandler(function(err, dom) {
    if (err) done(err);
    done(null, domToElement(dom));
  });
  const parser = new htmlparser.Parser(handler);
  parser.write(rawHtml);
  parser.done();
}

htmlparser2-without-node-native

htmlparser2 build that excludes node native modules so that you can use it in platforms like React Native.

MIT
Latest version published 7 years ago

Package Health Score

65 / 100
Full package analysis