Пример #1
0
        //public static void TraceHtmlReader_v4(string file, bool generateCloseTag = false, bool disableLineColumn = false, bool disableScriptTreatment = false,
        //    bool useReadAttributeValue_v2 = true, bool useTranslateChar = true)
        public static void TraceHtmlReader_v4(string file, HtmlReaderOptions options = HtmlReaderOptions.Default)
        {
            string traceFile = GetFile(file, ".trace.v4.txt");

            Trace.WriteLine("HtmlReader v4");
            Trace.WriteLine("  file  \"{0}\"", file);
            Trace.WriteLine("  trace \"{0}\"", traceFile);
            //HtmlReader_v4.ReadFile(file, generateCloseTag: generateCloseTag, disableLineColumn: disableLineColumn, disableScriptTreatment: disableScriptTreatment,
            //    useReadAttributeValue_v2: useReadAttributeValue_v2, useTranslateChar: useTranslateChar)
            //    .zSave(traceFile);
            HtmlReader_v4.ReadFile(file, options: options).zSave(traceFile);
        }
Пример #2
0
        public static void Test_Trace_Html(string file)
        {
            string traceFile                = file + ".html.trace";
            bool   generateCloseTag         = true;
            bool   disableLineColumn        = false;
            bool   disableScriptTreatment   = false;
            bool   useReadAttributeValue_v2 = true;
            bool   useTranslateChar         = true;

            HtmlReader_v4.ReadFile(file, generateCloseTag: generateCloseTag, disableLineColumn: disableLineColumn, disableScriptTreatment: disableScriptTreatment,
                                   useReadAttributeValue_v2: useReadAttributeValue_v2, useTranslateChar: useTranslateChar)
            .zSave(traceFile, jsonIndent: true);
        }
Пример #3
0
        public static void Test_HtmlReader_v2_v4(string directory = null, string traceDirectory = null, string pattern = "*.html")
        {
            // compare HtmlReader_v2 and HtmlReader_v4
            // for each html file :
            //   - generate HtmlReader_v2 trace file .html.trace.v2.txt
            //   - generate HtmlReader_v4 trace file .html.trace.v4.txt
            //   - compare .html.trace.v2.txt with .html.trace.v4.txt

            bool deleteOkTrace = true;

            int nb           = 0;
            int okTraceNb    = 0;
            int notOkTraceNb = 0;

            foreach (string file in GetHtmlFiles(directory, pattern))
            {
                nb++;
                Trace.WriteLine("file \"{0}\"", file);

                string traceFile_v2 = GetFile(file, ".trace.v2.txt", traceDirectory);
                TraceHtmlReader_v2(file, traceFile_v2, disableScriptTreatment: false, textReplaceControl: false);

                string traceFile_v4 = GetFile(file, ".trace.v4.txt", traceDirectory);
                //HtmlReader_v4.ReadFile(file, generateCloseTag: false, disableLineColumn: true, disableScriptTreatment: false, useReadAttributeValue_v2: false,
                //    useTranslateChar: true)
                //    .zSave(traceFile_v4);
                //useReadAttributeValue_v2: false
                HtmlReader_v4.ReadFile(file, options: HtmlReaderOptions.Default | HtmlReaderOptions.DisableLineColumn).zSave(traceFile_v4, jsonIndent: true);

                if (zfile.AreFileEqual(traceFile_v2, traceFile_v4))
                {
                    okTraceNb++;
                    Trace.WriteLine("  trace files ok");
                    if (deleteOkTrace)
                    {
                        zFile.Delete(traceFile_v2);
                        zFile.Delete(traceFile_v4);
                    }
                }
                else
                {
                    notOkTraceNb++;
                    Trace.WriteLine("  trace files not identical");
                }
            }
            Trace.WriteLine();
            Trace.WriteLine("{0} files", nb);
            Trace.WriteLine("trace files : ok {0}, not ok {1}", okTraceNb, notOkTraceNb);
        }
Пример #4
0
        public static void FileHtmlToXml_v2(string file, string xmlFile, bool traceHtmlReader = false, bool traceHtmlToXml = false)
        {
            //HtmlReaderOptions options = HtmlReaderOptions.Default | HtmlReaderOptions.GenerateCloseTag;
            HtmlReaderOptions options = HtmlReaderOptions.Default;

            if (traceHtmlReader)
            {
                HtmlReader_v4.ReadFile(file, options: options | HtmlReaderOptions.DisableLineColumn).zSave(GetFile(file, ".HtmlReader.v4.txt"), jsonIndent: true);
            }

            using (StreamReader sr = zfile.OpenText(file))
            {
                HtmlReader_v4 htmlReader = new HtmlReader_v4(sr, options);
                HtmlToXml_v3  htmlToXml  = new HtmlToXml_v3(htmlReader);
                htmlToXml.CreateXml().Save(xmlFile);
                if (traceHtmlToXml)
                {
                    htmlToXml.Log.zSave(GetFile(file, ".HtmlToXml.v2.json"));
                }
            }
        }