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.

31 lines
634 B

3 months ago
  1. 'use strict';
  2. const { detachNodeFromParent } = require('../lib/xast.js');
  3. exports.name = 'removeComments';
  4. exports.type = 'visitor';
  5. exports.active = true;
  6. exports.description = 'removes comments';
  7. /**
  8. * Remove comments.
  9. *
  10. * @example
  11. * <!-- Generator: Adobe Illustrator 15.0.0, SVG Export
  12. * Plug-In . SVG Version: 6.00 Build 0) -->
  13. *
  14. * @author Kir Belevich
  15. *
  16. * @type {import('../lib/types').Plugin<void>}
  17. */
  18. exports.fn = () => {
  19. return {
  20. comment: {
  21. enter: (node, parentNode) => {
  22. if (node.value.charAt(0) !== '!') {
  23. detachNodeFromParent(node, parentNode);
  24. }
  25. },
  26. },
  27. };
  28. };