Change how spaces are handled

I am not sure exactly when this started to happen but I recently switched to 0.84 and then 0.85 and noticed that in many of my templates spaces are collapsing more often than they used to. For example something like this:

<div class="modal-body" data-bind="if: fydSummary()">
        You finished
        <span data-bind="text: summary().count"></span> your Project,
        answering <span data-bind="text: summary().total"></span> of
        <span data-bind="text: summary().count"></span>
        correctly.
      </div>

no longer includes the spaces surrounding or internal to any tags. Even adding an explicit [[ " " }} still gets collapsed during minify. This was working with older versions since I just recently switched from .82.1. The minified output from the above is now:

<div class=modal-body data-bind="if: summary()">You finished
<span data-bind="text: summary().count"></span>your Project,
answering <span data-bind="text: summary().total"></span>of
<span data-bind="text: summary().count"></span>correctly.</div>

whereas it used to be and we require this
.82.1. The minified output from the above is now:

<div class=modal-body data-bind="if: summary()">You finished
<span data-bind="text: summary().count"></span> your Project,
answering <span data-bind="text: summary().total"></span> of
<span data-bind="text: summary().count"></span> correctly.</div>

Interestingly enough the space after the word “answering” is being preserved but the other ones are not anymore. I know that we can disable all whitespace collapsing with

minify:
  tdewolff:
    html:
      keepWhitespace: true

but it does feel more like a defect. In think when writing a template with.
<span class="highlight">Hugo</span> is cool. my gut feeling is that the output should include the space in front of the “is” and I think most people would assume that without fiddling with the HTML minimizer.

Your gut is smart.

I totally agree and have had a “gut feeling” about something wrong looking at some other reports.

1 Like