08e307e026460b1be8e6be2730c09685bd123be4d4b00e7a65ed7defdf5b5f4b514be7baa080d01c5450fc403771b84c4e9bfac9b49b7be04bcb64c551677a 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. const { detachNodeFromParent } = require('../lib/xast.js');
  3. exports.name = 'removeDoctype';
  4. exports.type = 'visitor';
  5. exports.active = true;
  6. exports.description = 'removes doctype declaration';
  7. /**
  8. * Remove DOCTYPE declaration.
  9. *
  10. * "Unfortunately the SVG DTDs are a source of so many
  11. * issues that the SVG WG has decided not to write one
  12. * for the upcoming SVG 1.2 standard. In fact SVG WG
  13. * members are even telling people not to use a DOCTYPE
  14. * declaration in SVG 1.0 and 1.1 documents"
  15. * https://jwatt.org/svg/authoring/#doctype-declaration
  16. *
  17. * @example
  18. * <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  19. * q"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  20. *
  21. * @example
  22. * <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  23. * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
  24. * <!-- an internal subset can be embedded here -->
  25. * ]>
  26. *
  27. * @author Kir Belevich
  28. *
  29. * @type {import('../lib/types').Plugin<void>}
  30. */
  31. exports.fn = () => {
  32. return {
  33. doctype: {
  34. enter: (node, parentNode) => {
  35. detachNodeFromParent(node, parentNode);
  36. },
  37. },
  38. };
  39. };