Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i clean the spaces and new lines?
    primarykey
    data
    text
    <p>I have the following output :</p> <blockquote> <p>(<strong>a lot of new lines here</strong>)</p> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p> <p>Lorem Ipsum has been the industry's standard dummy</p> <p>text ever since the 1500s, when an unknown printer took</p> <p>a galley of type and scrambled it to make a type specimen book.</p> <p>(<strong>a lot of new lines here</strong>)</p> <p>It has survived not only five centuries,</p> <p>but also the leap into electronic typesetting, </p> <p>remaining essentially unchanged. It was popularised</p> <p>in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,</p> </blockquote> <p>To clean this up i am using a lot of regex</p> <pre><code>var body = contentDiv.replace(/ {2,}/g, ' ').replace(/([^\r\n][^\n])(?:\r?\n)([^\r\n][^\n])/g,"$1$2"); $('eBody').value = body.replace(/\n{3,}/g, '\n').replace(/^\s\s*/, ''); </code></pre> <p>Where <code>contentDiv</code> is the text above and is returned by a <code>getElementsByTagName</code>.</p> <pre><code>var contentDiv = element.getElementsByTagName("div")[0].textContent; </code></pre> <p>It is just that the div has a lot of formatting ( ...), that when i call the <code>textContent</code> function, I do get the text with spaces and extra new lines, normally it should look like:</p> <blockquote> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload