NavigationItem.Link.ContentFileName is returning incorrectly
See original GitHub issueDescription
The library is returning the wrong text for ContentFileName. In the case for this epub, it should return “Text/chapter01.xhtml” while it is returning “Text/…/Text/chapter01.xhml”. I’m not sure where the extra relative path is coming from, given it’s not in the XML.
Epub structure:
Code:
var navItems = await book.GetNavigationAsync();
foreach (var navigationItem in navItems)
{
if (navigationItem.NestedItems.Count > 0)
{
var nestedChapters = new List<BookChapterItem>();
foreach (var nestedChapter in navigationItem.NestedItems)
{
if (nestedChapter.Link == null) continue;
// BUG: nestedChapter.Link.ContentFileName -> Is returning "/Text/../Text/chapter01.xhtml" when it should be "Text/chapter01.xhtml"
var key = BookService.CleanContentKeys(nestedChapter.Link.ContentFileName);
if (mappings.ContainsKey(key))
{
nestedChapters.Add(new BookChapterItem()
{
Title = nestedChapter.Title,
Page = mappings[key],
Part = nestedChapter.Link.Anchor ?? string.Empty,
Children = new List<BookChapterItem>()
});
}
}
CreateToCChapter(navigationItem, nestedChapters, chaptersList, mappings);
}
Toc.ncx:
<navPoint id="navPoint5">
<navLabel>
<text>Day 0: Backstory and the Bridal Wars</text>
</navLabel>
<content src="Text/chapter1.xhtml"/>
</navPoint>
<navPoint id="navPoint6">
<navLabel>
<text>Day 1, Morning: The Start of a Slow Life</text>
</navLabel>
<content src="Text/chapter2.xhtml"/>
</navPoint>
Manifest:
<manifest>
<item id="cover" href="Text/cover.xhtml" media-type="application/xhtml+xml"/>
<item id="frontmatter1.xhtml" href="Text/frontmatter1.xhtml" media-type="application/xhtml+xml"/>
<item id="frontmatter2.xhtml" href="Text/frontmatter2.xhtml" media-type="application/xhtml+xml"/>
<item id="toc.xhtml" href="Text/toc.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="prologue.xhtml" href="Text/prologue.xhtml" media-type="application/xhtml+xml"/>
<item id="prologue2.xhtml" href="Text/prologue2.xhtml" media-type="application/xhtml+xml"/>
<item id="insert1.xhtml" href="Text/insert1.xhtml" media-type="application/xhtml+xml"/>
<item id="prologue2_1.xhtml" href="Text/prologue2_1.xhtml" media-type="application/xhtml+xml"/>
<item id="chapter1.xhtml" href="Text/chapter1.xhtml" media-type="application/xhtml+xml"/>
...
Sample EPUB file
The file is under copyright
Additional context
This is a EPUB 2 document and I have tested on v3.1.1, v3.1.0 and it is not working.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
PDFKit | Apple Developer Forums
(During practical scenario, I can't use PDFView object, I have to use custom UIView and it will be needed support other customize operation...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have validated it is working. Thanks again.
No worries, let me publish it to Nuget then.