escapeHtml.js 464 B

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