This example
<code>mixin article
div
if block
block
+article Test
</code>
<code>mixin article
div
if block
block
+article Test
</code>
mixin article
div
if block
block
+article Test
When inspecting the code it looks like one space, but if we start editing the text node we will see this:
<code><div>Test
</div>
</code>
<code><div>Test
</div>
</code>
<div>Test
</div>
How to get rid of this?
There doesn’t seem to be a way to avoid this in Pug, but because of the way HTML handles whitespace it shouldn’t affect the way a page displays to the end user.
You could consider running an html formatting package after Pug runs to clean up Pug’s output.
Additionally, if your block truly is just a string, you could use a mixin parameter instead (but I doubt this is actually the case):
<code>mixin article(text)
div #{text}
+article('Test')
</code>
<code>mixin article(text)
div #{text}
+article('Test')
</code>
mixin article(text)
div #{text}
+article('Test')
<code><div>Test</div>
</code>
<code><div>Test</div>
</code>
<div>Test</div>