title: How to not remove some knockout-specific comments using grunt-contrib-htmlmin?
body: <p>I am trying to use <a href="https://github.com/gruntjs/grunt-contrib-htmlmin" rel="nofollow">grunt-contrib-html</a> to minify my html. The only problem that I am using knockout with <a href="http://knockoutjs.com/documentation/foreach-binding.html" rel="nofollow">containerless control flow syntax</a>, which is just html comments, but they are really important to knockout:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;This item always appears&lt;/li&gt;
      &lt;!-- ko if: someExpressionGoesHere --&gt;
          &lt;li&gt;I want to make this item present/absent dynamically&lt;/li&gt;
      &lt;!-- /ko --&gt;
  &lt;/ul&gt;
  
  &lt;!-- ko foreach: myItems --&gt;
      &lt;li&gt;Item &lt;span data-bind="text: $data"&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;!-- /ko --&gt;
  </code></pre>
  
  <p>So when I use minifier with the following options:</p>
  
  <pre><code>options: {
     removeComments: true,
     collapseWhitespace: true
  }
  </code></pre>
  
  <p>the application is not working after minification (not surprise, it removes <code>&lt;!-- ko comments</code> ). Removing <code>removeComments</code> solves the problem, but my html has a lot of comments and only few of them are knockout specific. Moreover all knockout comments are easily recognizable: they have <code>&lt;!-- ko</code> in the beginning and <code>&lt;!-- /ko --&gt;</code> in the end.</p>
  
  <p>Looking for underlying <a href="https://github.com/kangax/html-minifier#options-quick-reference" rel="nofollow">html minifier options</a> - there is nothing like "handle correctly knockout comments".</p>
  
  <p>So is there a way to solve my problem: minify html removing comments, but leaving knockout specific comments?</p>