escapeHtml.js 488 B

123456789101112131415161718192021
  1. /**
  2. * Escape HTML tags in descriptions.
  3. *
  4. * @module plugins/escapeHtml
  5. */
  6. 'use strict';
  7. exports.handlers = {
  8. /**
  9. * Translate HTML tags in descriptions into safe entities. Replaces <, & and newlines
  10. */
  11. newDoclet: function(e) {
  12. if (e.doclet.description) {
  13. e.doclet.description = e.doclet.description
  14. .replace(/&/g, '&amp;')
  15. .replace(/</g, '&lt;')
  16. .replace(/\r\n|\n|\r/g, '<br>');
  17. }
  18. }
  19. };