Closed jaryway closed 5 years ago
It's so because regex checks for comments that has space after //: file: StreamReaderExtension.cs Lines 148-149
// Replace line comments
htmlContents = Regex.Replace(htmlContents, @"// (.*?)\r?\n", "", RegexOptions.Singleline);
I have simply removed the space and everything is fine for my case.
@nevaldas your solution remove also some code like:
This opens and interesting question, what should happen on something like:
<div>
<pre>test // Hello World </pre>
</div>
At the very least the replacement of line comments: https://github.com/deanhume/html-minifier/blob/master/ViewMinifier/StreamReaderExtension.cs#L148
Should be inside the
if (!features.IgnoreHtmlComments)
Closing this issue as it is not something that will likely be fixed.
This is due to a number of reasons:
The 1st reason is true, however, it does not take into account hardcoded texts that might contain such things, for instance, auto-generated html files that might contain product description, which might contain // (which would not represent any comment, especially when HTML comments don't start in such a way). A great example was given by heldersepu. Also, another reason to have HTML comments left would be usage of libraries like Knockout (that you support in this library). I truly understand that this issue is not easy (or nearly impossible) to fix, but yet, there are some reasons for such things to be left. One solution might be to allow overriding rules for specific files. For instance, skip "//" replacement in auto-generated/*/.cshtml files. Not sure how useful it would be for others, but would have been very useful in my case.
test:
to