If an element contains children then their text is concatenated without any white space in between, whereas it is expected that they would be separated by a space. For example:
const cheerio = require('cheerio');
const ch = cheerio.load('<body><div id="1">Some text in the div.</div><div id="2">There should be a space before this line.</div></body>');
ch('body').text();
Results in:
'Some text in the div.There should be a space before this line.'
But in many cases, the text should be separated resulting in:
'Some text in the div. There should be a space before this line.'
text() should provide an option to compulsorily separate children with a space.
This behavior is equivalent to jQuery.
So what was the solution ?