Skip to content

Instantly share code, notes, and snippets.

@stonezhl
Last active August 21, 2019 03:29
Show Gist options
  • Save stonezhl/0749ae51bd25da1a693656b28bb4e9fd to your computer and use it in GitHub Desktop.
Save stonezhl/0749ae51bd25da1a693656b28bb4e9fd to your computer and use it in GitHub Desktop.
OPFSpine Struct
import Kanna
struct OPFSpine {
private(set) var idrefs = [String]()
init?(package: XMLElement) {
guard let spine = package.at_xpath("opf:spine", namespaces: XPath.opf.namespace) else { return nil }
idrefs = spine.xpath("opf:itemref[@idref]/@idref", namespaces: opfNamespace)
.map { $0.text }
.compactMap { $0 }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment