Skip to content

Commit

Permalink
Updates package 'AngleSharp' to version '0.11.0' (#376)
Browse files Browse the repository at this point in the history
* Updates AngleSharp api usage
  • Loading branch information
MicrosoftHealthService authored and brendankowitz committed Mar 18, 2019
1 parent 689eec8 commit 135003f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions THIRDPARTYNOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Do Not Translate or Localize

This file is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.

## AngleSharp 0.9.11
## AngleSharp 0.11.0
* Component Source: https://github.com/AngleSharp/AngleSharp/
* Component Copyright and License:
> The MIT License (MIT)
>
> Copyright (c) 2013 - 2018 AngleSharp
> Copyright (c) 2013 - 2019 AngleSharp
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
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.1.3" />
<PackageReference Include="MediatR" Version="6.0.0" />
Expand Down

0 comments on commit 135003f

Please sign in to comment.