示例#1
0
        private void InitializeAndLock()
        {
            this.locked = true;
            ConverterInput converterInput;

            if (this.input is Stream)
            {
                if (this.inputEncoding == null)
                {
                    throw new InvalidOperationException(TextConvertersStrings.InputEncodingRequired);
                }
                converterInput = new ConverterDecodingInput((Stream)this.input, false, this.inputEncoding, this.detectEncodingFromByteOrderMark, TextConvertersDefaults.MaxTokenSize(this.testBoundaryConditions), TextConvertersDefaults.MaxHtmlMetaRestartOffset(this.testBoundaryConditions), 16384, this.testBoundaryConditions, this, null);
            }
            else
            {
                converterInput = new ConverterUnicodeInput(this.input, false, TextConvertersDefaults.MaxTokenSize(this.testBoundaryConditions), this.testBoundaryConditions, null);
            }
            HtmlParser htmlParser = new HtmlParser(converterInput, false, false, TextConvertersDefaults.MaxTokenRuns(this.testBoundaryConditions), TextConvertersDefaults.MaxHtmlAttributes(this.testBoundaryConditions), this.testBoundaryConditions);

            if (this.normalizeInputHtml)
            {
                this.parser = new HtmlNormalizingParser(htmlParser, null, false, TextConvertersDefaults.MaxHtmlNormalizerNesting(this.testBoundaryConditions), this.testBoundaryConditions, this.testNormalizerTraceStream, this.testNormalizerTraceShowTokenNum, this.testNormalizerTraceStopOnTokenNum);
                return;
            }
            this.parser = htmlParser;
        }
示例#2
0
        private IProducerConsumer CreateChain(ConverterInput input, ConverterOutput output, IProgressMonitor progressMonitor)
        {
            this.locked = true;
            HtmlInjection injection = null;

            if (this.injectHead != null || this.injectTail != null)
            {
                injection = new HtmlInjection(this.injectHead, this.injectTail, this.injectionFormat, this.filterHtml, this.htmlCallback, this.testBoundaryConditions, null, progressMonitor);
            }
            HtmlParser            parser  = new HtmlParser(input, this.detectEncodingFromMetaTag, false, TextConvertersDefaults.MaxTokenRuns(this.testBoundaryConditions), TextConvertersDefaults.MaxHtmlAttributes(this.testBoundaryConditions), this.testBoundaryConditions);
            HtmlNormalizingParser parser2 = new HtmlNormalizingParser(parser, injection, false, TextConvertersDefaults.MaxHtmlNormalizerNesting(this.testBoundaryConditions), this.testBoundaryConditions, this.testNormalizerTraceStream, this.testNormalizerTraceShowTokenNum, this.testNormalizerTraceStopOnTokenNum);
            HtmlWriter            writer  = new HtmlWriter(output, this.filterHtml, true);
            FormatOutput          output2 = new HtmlFormatOutput(writer, null, this.OutputFragment, this.TestFormatTraceStream, this.TestFormatOutputTraceStream, this.filterHtml, this.htmlCallback, false);

            return(new HtmlFormatConverter(parser2, output2, false, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum, this.TestFormatConverterTraceStream, progressMonitor));
        }