removeXMLProcInst.js 610 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const { detachNodeFromParent } = require('../lib/xast.js');
  3. exports.name = 'removeXMLProcInst';
  4. exports.type = 'visitor';
  5. exports.active = true;
  6. exports.description = 'removes XML processing instructions';
  7. /**
  8. * Remove XML Processing Instruction.
  9. *
  10. * @example
  11. * <?xml version="1.0" encoding="utf-8"?>
  12. *
  13. * @author Kir Belevich
  14. *
  15. * @type {import('../lib/types').Plugin<void>}
  16. */
  17. exports.fn = () => {
  18. return {
  19. instruction: {
  20. enter: (node, parentNode) => {
  21. if (node.name === 'xml') {
  22. detachNodeFromParent(node, parentNode);
  23. }
  24. },
  25. },
  26. };
  27. };