You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
697 B

  1. 'use strict';
  2. const Parser = require('./parser');
  3. const Serializer = require('./serializer');
  4. // Shorthands
  5. exports.parse = function parse(html, options) {
  6. const parser = new Parser(options);
  7. return parser.parse(html);
  8. };
  9. exports.parseFragment = function parseFragment(fragmentContext, html, options) {
  10. if (typeof fragmentContext === 'string') {
  11. options = html;
  12. html = fragmentContext;
  13. fragmentContext = null;
  14. }
  15. const parser = new Parser(options);
  16. return parser.parseFragment(html, fragmentContext);
  17. };
  18. exports.serialize = function(node, options) {
  19. const serializer = new Serializer(node, options);
  20. return serializer.serialize();
  21. };