{"id":20010098,"url":"https://github.com/cxa/fpub","last_synced_at":"2025-05-04T19:36:00.089Z","repository":{"id":138075893,"uuid":"116037496","full_name":"cxa/Fpub","owner":"cxa","description":"Library for reading EPUB file format built on top of .NET Standard 2.0 and F#.","archived":false,"fork":false,"pushed_at":"2024-01-06T07:22:26.000Z","size":331,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T14:50:36.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cxa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-01-02T16:58:04.000Z","updated_at":"2024-01-12T14:47:24.000Z","dependencies_parsed_at":"2024-01-06T08:29:03.928Z","dependency_job_id":"46577beb-6189-4c1b-891a-8448f9e96a4b","html_url":"https://github.com/cxa/Fpub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FFpub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FFpub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FFpub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FFpub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cxa","download_url":"https://codeload.github.com/cxa/Fpub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252390793,"owners_count":21740386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T07:18:28.114Z","updated_at":"2025-05-04T19:35:59.586Z","avatar_url":"https://github.com/cxa.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fpub\n\nLibrary for reading EPUB file format built on top of .NET Standard 2.0 and F#.\n\nSafe, simple and extendable.\n\nAvailable on NuGet: \u003chttps://www.nuget.org/packages/com.realazy.fpub/\u003e\n\n## Simple things should be simple\n\n```fsharp\nmodule Container = begin\n  type T\n\n  // Open EPUB\n  val withStream : stream:System.IO.Stream -\u003e Result\u003cT,exn\u003e\n  val withFile : file:string -\u003e Result\u003cT,exn\u003e\n\n  // Get resource from EPUB with path\n  val getResource : T -\u003e path:string -\u003e Result\u003cSystem.IO.Stream,exn\u003e\n\n  // Get EPUB package document\n  val getPackagePaths : container:T -\u003e Result\u003cseq\u003cstring\u003e,exn\u003e\n  val getDefaultPackage : container:T -\u003e Result\u003cPackage.T,exn\u003e\n\n  // Get EPUB navigation document\n  val getNav : container:T -\u003e Result\u003cNav.T,exn\u003e\n\n  // Get EPUB 2 NCX document (until navigation document is missing)\n  val getNcx : container:T -\u003e Result\u003cNcx.T,exn\u003e\nend\n\n// Read Package Document\nmodule Package = begin\n  module Metadata = begin\n    type T\n    val getElement : T -\u003e Element.T\n    val getUniqueIdentifier : T -\u003e Result\u003cstring,exn\u003e\n    val getReleaseIdentifier : metadata:T -\u003e Result\u003cstring,exn\u003e\n    val getAllIdentifiers : T -\u003e Result\u003cseq\u003cstring\u003e,exn\u003e\n    val getSchemeIdentifiers : T -\u003e Result\u003cMap\u003cstring,string\u003e,exn\u003e\n    val getTitle : T -\u003e Result\u003cstring,exn\u003e\n    val getLanguage : T -\u003e Result\u003cstring,exn\u003e\n    val getCreators : T -\u003e Result\u003cseq\u003cstring\u003e,exn\u003e\n    val getContributors : T -\u003e Result\u003cseq\u003cstring\u003e,exn\u003e\n    val getDate : T -\u003e Result\u003cSystem.DateTime,exn\u003e\n  end\n\n  module Manifest = begin\n    type T\n    val getElement : T -\u003e Element.T\n    module Item = begin\n      type T\n      val getElement : T -\u003e Element.T\n      val getAttribute : attribute:string -\u003e T -\u003e Result\u003cstring,exn\u003e\n      val getId : item:T -\u003e Result\u003cstring,exn\u003e\n      val getHref : item:T -\u003e Result\u003cstring,exn\u003e\n      val getMediaType : item:T -\u003e Result\u003cstring,exn\u003e\n      val getResourcePath : item:T -\u003e Result\u003cstring,exn\u003e\n    end\n    val getItems : T -\u003e Result\u003cseq\u003cItem.T\u003e,exn\u003e\n    val getItemById : id:string -\u003e T -\u003e Result\u003cItem.T,exn\u003e\n    val getNavItem : T -\u003e Result\u003cItem.T,exn\u003e\n    val getCoverImageItem : item:T -\u003e Result\u003cItem.T,exn\u003e\n  end\n  module Spine = begin\n    type T\n    val getElement : T -\u003e Element.T\n    module ItemRef = begin\n      type T\n      val getElement : T -\u003e Element.T\n      val getId : T -\u003e Result\u003cstring,exn\u003e\n      val getLinear : T -\u003e Result\u003cbool,exn\u003e\n      val getProperties : T -\u003e Result\u003cstring,exn\u003e\n      val getIdref : T -\u003e Result\u003cstring,exn\u003e\n      val getManifestItem :\n        itemRef:T -\u003e element:Manifest.T -\u003e Result\u003cManifest.Item.T,exn\u003e\n    end\n    module PageProgressionDirection = begin\n      type T =\n        | Ltr\n        | Rtl\n        | Default\n    end\n    val getPageProgressionDirection : T -\u003e PageProgressionDirection.T\n    val getItemRefs : T -\u003e Result\u003cseq\u003cItemRef.T\u003e,exn\u003e\n  end\n  type T\n  val withFile : uri:string -\u003e pkgDir:string -\u003e Result\u003cT,exn\u003e\n  val withStream : stream:System.IO.Stream -\u003e pkgDir:string -\u003e Result\u003cT,exn\u003e\n  val getElement : T -\u003e Element.T\n  val getVersion : T -\u003e Result\u003cdouble,exn\u003e\n  val getUniqueIdentifier : T -\u003e Result\u003cstring,exn\u003e\n  val getMetadata : T -\u003e Result\u003cMetadata.T,exn\u003e\n  val getManifest : T -\u003e Result\u003cManifest.T,exn\u003e\n  val getSpine : T -\u003e Result\u003cSpine.T,exn\u003e\n  val getNavDocPath : T -\u003e Result\u003cstring,exn\u003e\n  val getNcxPath : package:T -\u003e Result\u003cstring,exn\u003e\nend\n\n// Navigating\n\ntype TocItem = // Table of contents item\n  {title: string;\n    resourcePath: string option;\n    subitems: TocItem array;}\n\n// Use EPUB3 navigation document\nmodule Nav = begin\n  module Toc = begin\n    type T\n    val getHeadingTitle : T -\u003e Result\u003cstring,exn\u003e\n    val getItems : T -\u003e TocItem []\n  end\n  module Landmarks = begin\n    type Item =\n      {title: string;\n        type: string;\n        resourcePath: string;\n        subitems: Item array;}\n    type T\n    val getHeadingTitle : T -\u003e Result\u003cstring,exn\u003e\n    val getItems : T -\u003e Item []\n  end\n  module PageList = begin\n    type T\n    val getHeadingTitle : T -\u003e Result\u003cstring,exn\u003e\n    val getPages : T -\u003e Map\u003cstring,string\u003e\n  end\n  type T\n  val withFile : uri:string -\u003e docDir:string -\u003e Result\u003cT,exn\u003e\n  val withStream : stream:System.IO.Stream -\u003e docDir:string -\u003e Result\u003cT,exn\u003e\n  val getElement : T -\u003e Element.T\n  val getToc : T -\u003e Result\u003cToc.T,exn\u003e\n  val getLandmarks : T -\u003e Result\u003cLandmarks.T,exn\u003e\n  val getPageList : T -\u003e Result\u003cPageList.T,exn\u003e\nend\n\n// Use EPUB2 Ncx when EPUB3 navigation documen is missing\nmodule Ncx = begin\n  module Toc = begin\n    type T\n    val getItems : T -\u003e TocItem []\n  end\n  module PageList = begin\n    type T\n    val getPages : T -\u003e Map\u003cstring,string\u003e\n  end\n  type T\n  val withFile : uri:string -\u003e docDir:string -\u003e Result\u003cT,exn\u003e\n  val withStream : stream:System.IO.Stream -\u003e docDir:string -\u003e Result\u003cT,exn\u003e\n  val getElement : T -\u003e Element.T\n  val getToc : T -\u003e Result\u003cToc.T,exn\u003e\n  val getPageList : T -\u003e Result\u003cPageList.T,exn\u003e\nend\n```\n\n## Complex things should be possible\n\n`Package`, `Nav`, `Ncx` and their submodules are abstracted in `Element.T`, which is an XML Element. Using `Element` to retrieve any information you needed.\n\n```fsharp\nmodule Element = begin\n  type T\n  val getValue : T -\u003e string\n  val getAttribute : name:string -\u003e T -\u003e Result\u003cstring,exn\u003e\n  val eval : xpath:string -\u003e T -\u003e Result\u003cobj,exn\u003e\n  val evalToString : xpath:string -\u003e element:T -\u003e Result\u003cstring,exn\u003e\n  val evalToDouble : xpath:string -\u003e element:T -\u003e Result\u003cdouble,exn\u003e\n  val evalToBoolean : xpath:string -\u003e element:T -\u003e Result\u003cbool,exn\u003e\n  val evalToElements : xpath:string -\u003e element:T -\u003e Result\u003cseq\u003cT\u003e,exn\u003e\n  val getFirstElement : xpath:string -\u003e T -\u003e Result\u003cT,exn\u003e\n  val getAllElements : xpath:string -\u003e T -\u003e Result\u003cseq\u003cT\u003e,exn\u003e\nend\n```\n\n## License\n\nMIT\n\n## Author\n\n- Blog: [realazy.com](https://realazy.com) (Chinese)\n- Github: [@cxa](https://github.com/cxa)\n- X: [@\\_realazy](https://x.com/_realazy) (Chinese mainly)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2Ffpub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxa%2Ffpub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2Ffpub/lists"}