Skip to content

Commit f07ea35

Browse files
committed
Add support for HTML entities in content docs
Leverage HtmlDocument for parsing. Fixes #3
1 parent d883e68 commit f07ea35

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Epub/Content.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.IO.Compression;
22
using System.Xml;
33
using System.Xml.Linq;
4+
using Devlooped.Web;
45

56
namespace Devlooped.Epub;
67

@@ -35,11 +36,8 @@ public XDocument Open()
3536
throw new InvalidArchiveException(ThisAssembly.Strings.MissingContent(Href));
3637

3738
using var stream = entry.Open();
38-
using var reader = XmlReader
39-
.Create(stream, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore })
40-
.IgnoreNamespaces();
4139

42-
return XDocument.Load(reader);
40+
return HtmlDocument.Load(stream);
4341
}
4442

4543
/// <summary>

src/Tests/PublicationTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ public void CanOpen()
2929
Assert.NotNull(pub);
3030
}
3131

32+
[Fact]
33+
public void CanReadContentFragments()
34+
{
35+
using var pub = Publication.Open(@"Samples/CCyC_Comentado_Tomo_II.epub");
36+
37+
Assert.NotNull(pub.Package.Navigation);
38+
39+
foreach (var nav in pub.Package.Navigation)
40+
{
41+
var content = nav.Open();
42+
}
43+
}
44+
3245
[Fact]
3346
public void CanAccessPackageInformation()
3447
{
847 KB
Binary file not shown.

0 commit comments

Comments
 (0)