deanhume / html-minifier

A simple command line tool to minify your HTML, Razor views & Web Forms views
http://deanhume.github.io/html-minifier/
MIT License
134 stars 86 forks source link

Razor @: error #18

Closed walterDurin closed 8 years ago

walterDurin commented 8 years ago

If a Razor page uses @: it might break as the html-minifier makes no special exceptions for it they should be on their own lines or at least end the line. @: requires line break to end tag.

@"@:(.*?)\r?\n" regex should find them, before minimization.

sawas commented 8 years ago

i have found that the inline commented code with // in razor block code the code after first comment will be commented.

the code

@{
int GridHeight = CTRL_K_GRID_HEIGHT_LG;
int GridWidth_Workflow = 100;//CTRL_K_GRID_COLUMN_LEN_LG;
int GridWidth_Request = 150;//CTRL_K_GRID_COLUMN_LEN_XL;
int GridWidth_Customer = 100;//CTRL_K_GRID_COLUMN_LEN_LG;
}

the minified code

@{ int GridHeight = CTRL_K_GRID_HEIGHT_LG;int GridWidth_Workflow = 100;//comment start here CTRL_K_GRID_COLUMN_LEN_LG;int GridWidth_Request = 150;//CTRL_K_GRID_COLUMN_LEN_XL;int GridWidth_Customer = 100;//CTRL_K_GRID_COLUMN_LEN_LG; }

edited : maybe it's my bad. i should to delete these comment thing before do the minification.

walterDurin commented 8 years ago

Your problem is that the inline comment detector requires one space following the // i believe this is intentional to stop stripping out http addresses ie http://www.google.com would be http: which would break i believe the fix from the pull request will fix it specifically "htmlContents = Regex.Replace(htmlContents, @"[^:|""|']//(.*?)\r?\n", "");"

deanhume commented 8 years ago

This has been fixed with the latest release https://github.com/deanhume/html-minifier/releases