Wondering what methods exist to preserve things like tabs and newlines when storing text in a JSON database? There are a couple ways I imagine going about this:
- Storing text in markup and reading the JSON string as html. (Not sure what the best methods are for this.)
- Storing JavaScript strings with \n and \t characters and trying to interpolate those characters properly i.e. not just printing "\nThis is a newline." Which it does by default.
EDIT: The example problem I'm having is using angular binding to print strings.
blogPost {
title: 'Hello There',
body: '\nThis is \ta test!'
}
Then in the html file:
<p>{{blogPost.body}}</p>
This renders 'This is a test' with no new line or tab but also not showing the \n \t characters. However when I use firebase console to store the string in the JSON object and call the storage from typescript I get the same object it prints like this '\nThis is \ta test!' with the characters showing (and not tabbing or newlining) both of which are undesirable behavior.
` and multiple ` ` – charlietfl Nov 18 '17 at 14:33