Created
February 5, 2015 19:52
-
-
Save cojahmetov/a5646164e6212ebd3b67 to your computer and use it in GitHub Desktop.
#js# content to html entities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function htmlEntities (str) { | |
| return String(str) | |
| .replace(/&/g, '&') | |
| .replace(/</g, '<') | |
| .replace(/>/g, '>') | |
| .replace(/"/g, '"'); | |
| } | |
| function toHtml(content) { | |
| var text = htmlEntities(content); | |
| var text = text.replace(/(?:\r\n|\r|\n)/g, '<br />'); | |
| return text; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment