Is it possible (and how can I) split a paragraph of text up into its respective lines with JavaScript. What I'd like to do is implement hanging punctuation on every line of a paragraph or blockquote, not just the starting line.
Any other ideas would be welcome too!
Clarification I was asked to be less ambiguous about what "split a paragraph into its respective lines" means.
In HTML a <p>
element creates a block of text. Similarly, so do many other elements. These bodies of text get wrapped to fit the width (whether that width is set by the css or assumed by the default setting) I can't seem to detect where the line breaks happen using regex or any other means. So let's say a paragraph ends up being 7 lines long, I'd like to be able to detect that it's seven lines, and where those lines start and end.
Looking for a \n
or a \r
doesn't seem to yield anything.