escapeHtmlChar.js 453 B

12345678910111213141516171819202122
  1. /** Used to map characters to HTML entities. */
  2. var htmlEscapes = {
  3. '&': '&',
  4. '<': '&lt;',
  5. '>': '&gt;',
  6. '"': '&quot;',
  7. "'": '&#39;',
  8. '`': '&#96;'
  9. };
  10. /**
  11. * Used by `_.escape` to convert characters to HTML entities.
  12. *
  13. * @private
  14. * @param {string} chr The matched character to escape.
  15. * @returns {string} Returns the escaped character.
  16. */
  17. function escapeHtmlChar(chr) {
  18. return htmlEscapes[chr];
  19. }
  20. module.exports = escapeHtmlChar;