private static void Main(string[] args)
		{
			Console.WriteLine("Zeta Html Compressor Console. http://zeta.li");
			Console.WriteLine();
			Console.WriteLine("Syntax: hc.exe <HTML input file path>");
			Console.WriteLine();

			if (args.Length != 1)
			{
				Console.Error.WriteLine("No input file specified or invalid number of arguments ({0} found).", args.Length);
			}
			else
			{
				var inputFilePath = args[0];
				var input = File.ReadAllText(inputFilePath);

				var compressor = new HtmlContentCompressor();
				var output = compressor.Compress(input);

				var outputFilePath =
					Path.Combine(
						Path.GetDirectoryName(inputFilePath),
						Path.GetFileNameWithoutExtension(inputFilePath) + // @"-output" +
						Path.GetExtension(inputFilePath));

				if (File.Exists(outputFilePath)) File.Delete(outputFilePath);
				File.WriteAllText(outputFilePath, output, Encoding.UTF8);

				Console.WriteLine("Successfully written output file '{0}'.", outputFilePath);
			}
		}
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Zeta Html Compressor Console. http://zeta.li");
            Console.WriteLine();
            Console.WriteLine("Syntax: hc.exe <HTML input file path>");
            Console.WriteLine();

            if (args.Length != 1)
            {
                Console.Error.WriteLine("No input file specified or invalid number of arguments ({0} found).", args.Length);
            }
            else
            {
                var inputFilePath = args[0];
                var input         = File.ReadAllText(inputFilePath);

                var compressor = new HtmlContentCompressor();
                var output     = compressor.Compress(input);

                var outputFilePath =
                    Path.Combine(
                        Path.GetDirectoryName(inputFilePath),
                        Path.GetFileNameWithoutExtension(inputFilePath) +                         // @"-output" +
                        Path.GetExtension(inputFilePath));

                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }
                File.WriteAllText(outputFilePath, output, Encoding.UTF8);

                Console.WriteLine("Successfully written output file '{0}'.", outputFilePath);
            }
        }
Exemplo n.º 3
0
 public void BenchHtmlCompressor()
 {
     var compressor = new HtmlContentCompressor();
     var result     = compressor.Compress(html);
     var size       = result.Length;
     //File.WriteAllText(
     //    Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "HTMLStandard.min3.htm"),
     //    result);
 }
		public void Test02()
		{
			var comp = new HtmlContentCompressor();
            comp.AddPreservePattern(new Regex(@"<!-- PROTECTED: .*? -->", RegexOptions.Singleline | RegexOptions.IgnoreCase));

			var input = Resources.Html02a;
			var output = comp.Compress(input);

			Assert.IsNotEmpty(output);
			var ratio = Math.Round((double)output.Length / input.Length * 100.0, 2);
			Assert.IsTrue(ratio < 100.0);
		}
        public void MinifyHtml(string filepath)
        {
            HtmlContentCompressor contentCompressor = new HtmlContentCompressor();

            //read
            var html = File.ReadAllText(filepath);

            //compress
            var compressed = contentCompressor.Compress(html);

            //write
            File.WriteAllText(filepath, compressed);
        }
        public void Test02()
        {
            var comp = new HtmlContentCompressor();

            comp.AddPreservePattern(new Regex(@"<!-- PROTECTED: .*? -->", RegexOptions.Singleline | RegexOptions.IgnoreCase));

            var input  = Resources.Html02a;
            var output = comp.Compress(input);

            Assert.IsNotEmpty(output);
            var ratio = Math.Round((double)output.Length / input.Length * 100.0, 2);

            Assert.IsTrue(ratio < 100.0);
        }
Exemplo n.º 7
0
 public static string MinifyHTML(string html)
 {
     ZetaHtmlCompressor.HtmlContentCompressor compressor = new HtmlContentCompressor();
     return(compressor.Compress(html));
 }