Example #1
0
 public static HtmlReaderSettings ReadOnly(HtmlReaderSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     return((HtmlReaderSettings)settings.CloneReadOnly());
 }
Example #2
0
        private HtmlDocumentFragment LoadHtml(string html, HtmlReaderSettings settings)
        {
            settings = settings ?? HtmlReaderSettings.Default;

            var treeBuilder = settings.Mode.CreateTreeBuilder();

            BaseUri = settings.BaseUri;
            Append(treeBuilder.ParseFragment(
                       html,
                       settings.ContextElement,
                       settings.BaseUri,
                       HtmlParseErrorCollection.Tracking(settings.MaxErrors)
                       ));
            return(this);
        }
Example #3
0
 public HtmlReaderSettings(HtmlReaderSettings settings)
 {
     if (settings == null)
     {
         MaxErrors = -1;
     }
     else
     {
         MaxErrors            = settings.MaxErrors;
         KeepEntityReferences = settings.KeepEntityReferences;
         Mode    = settings.Mode;
         BaseUri = settings.BaseUri;
         Context = settings.Context;
     }
 }
Example #4
0
        private HtmlDocument LoadHtml(string html, HtmlReaderSettings settings)
        {
            settings = settings ?? HtmlReaderSettings.Default;

            var treeBuilder = settings.Mode.CreateTreeBuilder();

            treeBuilder.CreateDocument = uri => {
                BaseUri = uri;
                return(this);
            };

            treeBuilder.Parse(
                html,
                settings.BaseUri,
                HtmlParseErrorCollection.Tracking(settings.MaxErrors)
                );
            return(this);
        }
Example #5
0
 public static HtmlDocumentFragment Parse(string html, HtmlReaderSettings settings)
 {
     return(new HtmlDocumentFragment().LoadHtml(html, settings));
 }