Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #52 from iaomw/toc
Browse files Browse the repository at this point in the history
Improve the parsing logic for nav & ncx
  • Loading branch information
aferditamuriqi authored Apr 29, 2018
2 parents 0379db0 + e076dc7 commit afd8a92
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Sources/parser/EpubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ final public class EpubParser {
fillEncryptionProfile(forLinksIn: publication, using: drm)
try parseMediaOverlay(from: fetcher, to: &publication)
parseNavigationDocument(from: fetcher, to: &publication)
parseNcxDocument(from: fetcher, to: &publication)

if publication.tableOfContents.isEmpty || publication.pageList.isEmpty {
parseNcxDocument(from: fetcher, to: &publication)
}
}
container.drm = drm
return ((publication, container), parseRemainingResource)
Expand Down Expand Up @@ -220,14 +223,13 @@ final public class EpubParser {
let newPageListItems = NavigationDocumentParser.pageList(fromNavigationDocument: navDocument,
locatedAt: navigationDocumentPath)

//publication.tableOfContents.append(contentsOf: newTableOfContentsItems)
publication.tableOfContents = newTableOfContentsItems
publication.landmarks.append(contentsOf: newLandmarksItems)
publication.listOfAudioFiles.append(contentsOf: newListOfAudiofiles)
publication.listOfIllustrations.append(contentsOf: newListOfIllustrations)
publication.listOfTables.append(contentsOf: newListOfTables)
publication.listOfVideos.append(contentsOf: newListOfVideos)
publication.pageList.append(contentsOf: newPageListItems)
publication.landmarks = newLandmarksItems
publication.listOfAudioFiles = newListOfAudiofiles
publication.listOfIllustrations = newListOfIllustrations
publication.listOfTables = newListOfTables
publication.listOfVideos = newListOfVideos
publication.pageList = newPageListItems
}

/// Attempt to fill `Publication.tableOfContent`/`.pageList` using the NCX
Expand Down

0 comments on commit afd8a92

Please sign in to comment.