public static HtmlReaderSettings ReadOnly(HtmlReaderSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } return((HtmlReaderSettings)settings.CloneReadOnly()); }
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); }
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; } }
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); }
public static HtmlDocumentFragment Parse(string html, HtmlReaderSettings settings) { return(new HtmlDocumentFragment().LoadHtml(html, settings)); }