Example #1
0
 /// <summary>
 /// Parses input markup, and executes configured cleanup and repair operations.
 /// </summary>
 public void CleanAndRepair()
 {
     if (fromString)
     {
         EncodingType tempEnc = this.InputCharacterEncoding;
         this.InputCharacterEncoding = EncodingType.Utf8;
         PInvoke.tidyParseString(this.handle, this.htmlString);
         this.InputCharacterEncoding = tempEnc;
     }
     else
     {
         InputSource input = new InputSource(this.stream);
         PInvoke.tidyParseSource(this.handle, ref input.TidyInputSource);
     }
     PInvoke.tidyCleanAndRepair(this.handle);
     cleaned = true;
 }
Example #2
0
 /// <summary>
 /// Parses input markup, and executes configured cleanup and repair operations.
 /// </summary>
 /// <param name="logStream">A stream to which errors encountered during the CleanAndRepair operation will be written to.</param>
 public void CleanAndRepair(Stream logStream)
 {
     //Config Error
     EncodingType tempOutEnc = this.OutputCharacterEncoding;
     this.OutputCharacterEncoding = EncodingType.Utf8;
     OutputSink sink = new OutputSink(logStream);
     PInvoke.tidySetErrorSink(this.handle, ref sink.TidyOutputSink);
     if (fromString)
     {
         EncodingType tempEnc = this.InputCharacterEncoding;
         this.InputCharacterEncoding = EncodingType.Utf8;
         PInvoke.tidyParseString(this.handle, this.htmlString);
         this.InputCharacterEncoding = tempEnc;
     }
     else
     {
         InputSource input = new InputSource(this.stream);
         PInvoke.tidyParseSource(this.handle, ref input.TidyInputSource);
     }
     PInvoke.tidyCleanAndRepair(this.handle);
     this.OutputCharacterEncoding = tempOutEnc;
     cleaned = true;
 }
Example #3
0
        /// <summary>
        /// Parses input markup, and executes configured cleanup and repair operations.
        /// </summary>
        /// <param name="logStream">A stream to which errors encountered during the CleanAndRepair operation will be written to.</param>
        public void CleanAndRepair(Stream logStream)
        {
            //Config Error
            EncodingType tempOutEnc = this.OutputCharacterEncoding;
            this.OutputCharacterEncoding = EncodingType.Utf8;
            OutputSink sink = new OutputSink(logStream);
            PInvoke.tidySetErrorSink(this.handle, ref sink.TidyOutputSink);
            if (fromString)
            {
	            using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlString)))
	            {
					InputSource input = new InputSource(memStream);
					PInvoke.tidyParseSource(handle, ref input.TidyInputSource);
	            }
            }
            else
            {
                InputSource input = new InputSource(this.stream);
                PInvoke.tidyParseSource(this.handle, ref input.TidyInputSource);
            }
            PInvoke.tidyCleanAndRepair(this.handle);
            this.OutputCharacterEncoding = tempOutEnc;
            cleaned = true;
        }