private void CompressHtml(string file) { var html = File.ReadAllText(file); html = _htmlCompressor.Compress(html); File.WriteAllText(file, html); }
public static void Main(string[] args) { var compressor = new HtmlCompressor(); compressor.Preservers.Add(new Preserver(new Regex("<!--\\s*build.*?\\s*-->", RegexOptions.Singleline | RegexOptions.IgnoreCase))); compressor.Preservers.Add(new Preserver(new Regex("<!--\\s*endbuild.*?\\s*-->", RegexOptions.Singleline | RegexOptions.IgnoreCase))); compressor.Settings.SurroundingSpaces = SurroundingSpaces.RemoveForAllTags; var text = compressor.Compress(File.ReadAllText(@"D:\B\BrandlessConsulting\Projects\Hazception\Code\Web\Client.Web\src\Hazception.Client.Web.FrontEnd\wwwroot\index.html")); File.WriteAllText(@"D:\Temp\compressed.html", text); }
protected override string GenerateBlock(Match match) { return(match.Groups[1].Value + _clone.Compress(match.Groups[2].Value) + match.Groups[3].Value); }