Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates package 'AngleSharp' to version '0.11.0' #376

Merged
merged 3 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
using System.Linq;
using AngleSharp;
using AngleSharp.Dom;
using AngleSharp.Dom.Events;
using AngleSharp.Dom.Html;
using AngleSharp.Extensions;
using AngleSharp.Html;
using AngleSharp.Parser.Html;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Dom.Events;
using AngleSharp.Html.Parser;
using EnsureThat;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -173,12 +172,11 @@ public IEnumerable<string> Validate(string html)
{
var errors = new List<HtmlErrorEvent>();
var options = new HtmlParserOptions { IsStrictMode = false };
var context = BrowsingContext.New(Configuration.Default);
context.ParseError += (sender, error) => errors.Add((HtmlErrorEvent)error);
var parser = new HtmlParser(options);

var parser = new HtmlParser(options, context);
parser.Error += (sender, error) => errors.Add((HtmlErrorEvent)error);

var dom = parser.ParseFragment(string.Format(HtmlTemplate, html), null);
var dom = parser.ParseDocument(string.Format(HtmlTemplate, html));

// Report parsing errors
if (errors.Any())
Expand All @@ -191,7 +189,7 @@ public IEnumerable<string> Validate(string html)
yield break;
}

var htmlBodyElement = dom.OfType<IHtmlHtmlElement>().FirstOrDefault()
var htmlBodyElement = dom.Children.OfType<IHtmlHtmlElement>().FirstOrDefault()
?.Children.OfType<IHtmlBodyElement>().FirstOrDefault();

// According to https://www.hl7.org/fhir/narrative.html
Expand Down Expand Up @@ -239,7 +237,7 @@ public string Sanitize(string html)
{
var parser = new HtmlParser();

using (var dom = parser.Parse(string.Format(HtmlTemplate, html)))
using (var dom = parser.ParseDocument(string.Format(HtmlTemplate, html)))
{
var containerDiv = dom.Body.Children.OfType<IHtmlDivElement>().FirstOrDefault();
if (containerDiv == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="0.9.11" />
<PackageReference Include="AngleSharp" Version="0.11.0" />
<PackageReference Include="Ensure.That" Version="8.1.1" />
<PackageReference Include="FluentValidation" Version="8.0.101" />
<PackageReference Include="MediatR" Version="6.0.0" />
Expand Down