I realized that for posthtml-extend it makes sense to remove not only line breaks but all whitespace instead. Because it can interfere with formatting, when actual html is inside multiple nested control tags, i.e. <block> inside <extends>:
<extends src="foo.html">
<block name="bar">
<< Parasitic whitespace to the left (as well as a line break above and below)
</block>
</extends>
If there is whitespace in the middle of a string, then it remains untouched and definitely should be handled by html beautifier later:
<extends src="foo.html">
<block name="bar">
<< Parasitic whitespace to the left (as well as a line break above and below).
<< Parasitic whitespace to the left again, this time it gets inserted to the actual output
</block>
</extends>
Remove whitespace at the start/end of the first/last text node. Related: https://github.com/posthtml/posthtml-include/issues/19.
I realized that for
posthtml-extend
it makes sense to remove not only line breaks but all whitespace instead. Because it can interfere with formatting, when actual html is inside multiple nested control tags, i.e.<block>
inside<extends>
:If there is whitespace in the middle of a string, then it remains untouched and definitely should be handled by html beautifier later: