When I work with a text editor, it generates HTML code that I save in the database. On another page, I need to display only the first 100 characters of the text without counting the HTML tags.
For instance, let's say this is the HTML code saved in the database:
<p><span style="color:red; font-size:20px; font-family:Arial">
Here is the real text that I want to strip to 100 characters</span></p>
<p>Can be splited <b>between</b> multiple divs.
Here is some more text to be longer <p>
If I try to use substring in JavaScript, it would end up breaking the HTML code like so:
<p><span style="color:red; font-size:20px; font-family:Arial">
Here is the real text that I want to s
But what I actually want is to achieve this result:
<p><span style="color:red; font-size:20px; font-family:Arial">
Here is the real text that I want to strip to 100 characters</span></p>
<p>Can be splited <b>between</b> multiple divs.
H<p>
This project is developed using Angular 4, so any suggestions involving JS, Angular, CSS, HTML, or leveraging Node.js on the backend would be greatly appreciated.