<p style="width:60px"> This is just a sample text. It is a piece of text that doesn't really say anything meaningful.</p>
When this text is rendered as HTML, it would look like this:
This is just
a sample
text. It
is a piece
of text
that doesn't
really say
anything
meaningful.
If we were to split the above paragraph into separate paragraphs, line by line, the expected result would be:
<p style="width:60px">This is just</p>
<p style="width:60px">a sample</p>
<p style="width:60px">text. It</p>
<p style="width:60px">is a piece</p>
<p style="width:60px">of text</p>
<p style="width:60px">that doesn't</p>
<p style="width:60px">really say</p>
<p style="width:60px">anything</p>
<p style="width:60px">meaningful.</p>
Is it feasible to achieve this using Javascript?
By splitting the text in this way, I will be able to create my own pagination system for lengthy HTML content. Each group of paragraphs, within a certain height limit, will be contained in a single
<div class="page"></div>
. Ultimately, the entire HTML structure would be organized as follows:
<div id="page1" class="page">
<p>complete content</p>
<p>upper part of XXX</p>
</div>
<div id="page2" class="page">
<p>bottom part of XXX</p>
<p>...</p><p>...</p>
</div>