22 ms·
Tell HN: Today I learned Epub is just HTML/CSS
- mettamage 6y agoNote: it's simply the wiki page, but in all my years that I read .epub files I never bothered to check the wiki page. So it is to my surprise I found out that it's just some XML and HTML/CSS!
- sumtechguy 6y agoI had the same reaction when I found out word docx files are just zip files with a bunch of xml in there.
- doodpants 6y agoDocx was Microsoft's answer to the Open Document Format used by OpenOffice, which is also just zipped XML files.
- lucb1e 6y agoYou might be surprised to learn just how many files are zip files. Java software (jar, war): zip files Android packages (apk): zip files OpenDocument Format (odt, ods, odp): zip files Quake 3 / OpenArena / Urban Terror / etc. (pk3): zip files Firefox/Thunderbird/Chromium extensions (xpi, crx): zip files EPUB: :D
- ok123456 6y agonumpy's npz is also zip.
- sumtechguy 6y agoJust look for that PK in the first 2 bytes of the file and it is a good chance it is a zip file. That jar/war one has saved me a few times in figuring out what exactly the compiler did to a program.
- Turing_Machine 6y agoYeah, it is surprising at first, but after you think about it, maybe not so much. If you need to cram a bunch of files into one package, zip is the obvious candidate. There are well-tested libraries and apps for dealing with zips for essentially every language and operating system. As the saying goes, "don't mess with success".
- rvz 6y agocool.
- rvz 6y agoTo Downvoters: So there is something wrong with saying 'cool'? What is the problem this time? There is nothing malicious or 'offensive' than reacting to something by saying 'cool'. Come on. Care to explain yourselves this time?
- yakubin 6y agoI didn't downvote, but it's a low-effort comment that doesn't really add anything to the discussion. There is no information, no argument, no widening of context, no additional perspective, nothing. It also isn't an acknowledgement-type reply like "I see" ending a discussion. In other words, it decreases signal-to-noise ratio. You can compare it to "congrats" email chains at corps. EDIT: It would be ok in a live discussion. But on a forum, not so much.
- robin_reala 6y agoThe HN equivalent of a “cool” response is clicking the upvote button.
- rvz 6y agoExcuse me? Am I 'not allowed' to express my own opinion of this post via typing in text, even if it says 'cool'. I think I am getting tone-policed.
- notjustanymike 6y agoCrazy right? And then you realize you can publish a legitimate epub using a JAMStack, which means some of us may have turned our onboarding documentation into a book, preloaded it onto a cheap branded android tablet, and then sent it to our premium clients as marketing schwag!
- mettamage 6y agoThat sounds awesome! Wait, so you could actually do all of that and then let it interact with APIs as well? When JS gets involved like this, I can see some crazy applications in my mind packaged as an ".epub" book. I guess it depends on what reader you're targetting then. A quick cursory search shows that not all of them support JS. Makes sense to me.
- richeyryan 6y agoI used to work for a large US-based publisher with a big presence in education. I worked on the ePub parser and renderer written in React. As a company we basically took the standard and ran with it. Each book could have its own interactive widgets where kids could do reading comprehension questions or math problems and the system would capture all this for the teacher to grade. We had closed captioned audio for a lot books that the ePub reader would co-ordinate and play. Last I heard they abandoned all that for a completely proprietary format though. It's been the only situation where I've gotten elbow deep into implementing a specification. It was interesting feeling out the nuances and finding the optional parts of the spec that actually end up being important because it was all planned to fit together.
- inetknght 6y ago> Wait, so you could actually do all of that and then let it interact with APIs as well? With epub? I hope not! > I guess it depends on what reader you're targetting then. A quick cursory search shows that not all of them support JS. Makes sense to me. Any epub reader supporting javascript would very much be an antifeature.
- smnrchrds 6y ago
- rhapsodic 6y agoI wonder why I can't save an MS Word doc as an Epub.
- karol 6y agoDoes it mean you could build a better web for knowledge sharing than medium and similar? It seems epub only supports a subset of CSS.
- hosh 6y agoPeople sometimes want to preserve whole websites that they can then access and use in their personal library. (Or at least, back before the cloud and streaming got a lot of people off of developing and maintaining their own personal library). I am thinking of a scenario where, if there is a collapse (societal, economic, political, or technological), how can knowledge be disseminated and preserved in a resilient way?
- frosted-flakes 6y agoA printer?
- hosh 6y agoThat can work, although the paper should be acid-free, and there are probably considerations for the ink that I am ignorant of. Even better if the paper and ink can be made onsite, and the printer can is repairable by someone within the nearby geographical region.
- tannhaeuser 6y agoEpub is XHTML not HTML, though.
- frosted-flakes 6y agoXHTML is also valid HTML, so both are true.
- GoblinSlayer 6y agoIt went down the google hole in epub3.
- cwitty88 6y agoI was at a developer conference and one of the original Apple guys was there (name evades me at the moment). He mentioned that after they built webkit and wanted to move into the book space with the iPad launch that Steve Jobs wanted to reuse all of the webkit work. They did that and made epub.
- ocdtrekkie 6y agoThis is why I'm super irritated Microsoft dropped EPUB support in Edge when switching to Chromium, and why it's so frustrating that EPUB support isn't common by default in operating systems: It's literally just HTML/CSS in an opinionated structure. EPUB should be as ubiquitously supported as PDF is today, no browser has an excuse for not supporting it.
- jrimbault 6y agoThe epub reader in old-Edge was quite nice.
- ocdtrekkie 6y agoIt really was. And just the fact that it was default-installed was a main perk: I could rely on it being on, say, a work PC, where I can't install software for personal use.
- Hammershaft 6y agoIt was the nicest one I've used on any platform. Now I read epubs on Apple books and I come away a little frustrated every time I use it (especially when I copy and paste)
- roryokane 6y ago> especially when I copy and paste You can make copy and paste work normally in Apple Books with the solutions on https://apple.stackexchange.com/q/137047 https://apple.stackexchange.com/q/137047 ‘Don't want iBooks to always paste the “Excerpt From” of what I have copied’.
- 908B64B197 6y agoThe PDF reader too. Wish they repackaged it as a standalone app.
- irrational 6y agoIf it is that easy, there must be a business/political reason for not supporting it. Does anyone have a clue what that might be?
- sto_hristo 6y ago- Wait, email and epub are just html? - points gun Always has been.
- rchaud 6y agoclearly it's not just html because if it was, dragging an epub file into the browser would display the book in a navigable format.
- adjav 6y agoYeah, it's compressed HTML/CSS with some additional XML files for use in navigation and DRM support.
- theandrewbailey 6y agoExcept for the time when email was plain text only.
- mattl 6y agoOr NeXT RTFd
- darkhorse13 6y agoDoes EPUB support JavaScript as well? And if it doesn't, are there any similar alternatives? Seems like a single file document that can also pull in data from somewhere could be pretty useful to say the least.
- rchaud 6y agoYou know how online newspaper articles have ads appearing in between paragraphs? That is precisely how JS would be implemented in epubs. Sure, we all have pleasant visions of truly interactive ebooks driven by creatively built JS content. But in the real world, ads would be the first thing to be added if JS was supported.
- darkhorse13 6y agoI know what you mean, I really do. But think of an interactive document that keeps updating itself with remote data. That sounds really cool to me.
- finiteseries 6y agoThat’s a website.
- darkhorse13 6y agoIt is. But you can't really run an HTML file locally without at least setting up some type of server (if you plan to make requests). And I know setting up a server is extremely easy, but it's almost impossible for someone who hasn't programmed before.
- vxNsr 6y agoThe point you’re missing is that if you just change the file extension of a ePub to html it will work fine in the browser. There’s nothing special going on. Just bec most .html files are served from a remote location that doesn’t mean they need to be, you can send someone a .html file as a download which they can open from their desktop, it will work just as well as an ePub file, in fact bec the browser recognizes the file ext it will likely run it better!
- open-source-ux 6y agoePub is a open format but as the wiki page states "it is supported by almost all hardware readers, except for Kindle". I can recommend Kobo as an e-ink e-reader that supports ePub with one caveat: Kobo requires you to sign-up for a Kobo account before you can even use the device - horrible. It's easy to search online to find a way to bypass this. Although Kobo is an alternative to Kindle, you won't find the range of titles that Amazon sells. However, I think e-readers are best for text-only, small paperback-sized books. Anything else simply doesn't fit the small screen and is inferior to the physical version of a title. (Amazon sells a lot of Kindle titles that are simply unsuitable for small e-reader screens.)
- m-p-3 6y agoOne of the benefit of EPUB is that text can be reflowed, so the display size doesn't matter much, unlike PDF which sets a specific page size. I'm not sure about the MOBI format, but I assume it has similar features to EPUB? At least it's possible to strip the DRM on Amazon books with the right set of tools, and Calibre is able to convert them to EPUB.
- Tagbert 6y agoMobi is very similar to EPub. It’s almost a 0.9 version of EPub. The main differences are in the container.
- open-source-ux 6y ago"One of the benefit of EPUB is that text can be reflowed, so the display size doesn't matter much" I do feel that the e-ink reader screen size does matter because reflowed text only works well for small, paperback-sized books. Any book larger than this small size that also features tables, charts, images, diagrams, code listings and more, will not display well on a small e-ink screen.
- rchaud 6y agoEpubs are basically what "motherfuckingwebsite.com" advocates for. Despite being HTML/CSS, the layouts aren't particularly interesting though. Most content reads from top to bottom, and the formatting is identical whether you read it on a phone or a tablet.
- alias_neo 6y agoI found this out last week when I bought a Kobo Forma and started converting all of my favourite Markdown documents to epub to stick on there. Calibre even lets you create a TOC by specifying the header regex (#, ##, etc for Markdown), it's great! had to edit a few manually to tweak layout and Calibre (https://calibre-ebook.com/ https://calibre-ebook.com/) has a nice editor for epubs built in.
- kemayo 6y agoIt's all at a very approachable level, too. I had to write an epub-maker as a necessary component for a project, and it turned out to be ~150 lines of python. You have to make a few indexes in XML and stick them into a zip file, basically. https://github.com/kemayo/leech/blob/master/ebook/epub.py https://github.com/kemayo/leech/blob/master/ebook/epub.py
- phuff 6y agoHey I did this, too! I forgot until just now :) https://github.com/phuff/epub_builder https://github.com/phuff/epub_builder I built it because I wanted to have something that made a daily brief news paper that was personalized and sent to my kindle. It makes an epub and uses kindlegen to convert it to a .mobi. There's a lot of fun epub formatting stuff you can do. Here's the system that makes the daily newspaper, but it's been so long I'm not sure it's actually functional code outside of my production version: https://github.com/phuff/steward https://github.com/phuff/steward
- deleted 6y ago[deleted]
- fnord77 6y agosounds like the kindle format (actually mostly .mobi) is moving towards html/css too
- thomond 6y agoIt's actually always used XHTML. Both .mobi and .epub is based on the Open Ebook format - https://en.wikipedia.org/wiki/Open_eBook https://en.wikipedia.org/wiki/Open_eBook
- prewett 6y agoWhen I checked, years ago, it seemed that .mobi included an embedded EPUB file. The books I checked also had it in the old format, presumably for compatibility, but I think I remember seeing something that this was not recommended as the only form.
- hoophoop 6y agoEpub can do all sort of homecalling / user tracking using HTML or CSS or javascript. What's even worse - almost all Epub readers don't do proper sandboxing.
- firefoxd 6y agoTo be a little pedantic, it's XHTML. I recently published a book and going through the w3c epub specifications was a pain. Instead, I bought a book I wanted to read then reversed engineered it. For small files you can use the w3c online validator, which will give you an overwhelming list of errors. Note: The kindle does not support epub, instead it uses kpf. For that you have to download a 333 MB program to convert your epubs.
- stewx 6y agoI learned this a while back and used the Python web page scraping tool BeautifulSoup to take an eBook version of a cookbook and generate individual recipe files compatible with my favourite recipe manager, Paprika.
- gbraad 6y ago... and still its an issue to open an epub on a desktop using a browser.
- neweraccount 6y agoOn Linux, I rename epub to zip, unzip it and use browser to read books.
- k_sze 6y agoIf you don't already know about Calibre, I wholeheartedly recommend it.
- ok123456 6y agoYou don't even need to load the books into calibre's database to view it. You can invoke 'ebook-viewer' from the command line directly with the epub file's path as the argument.
- ASalazarMX 6y agoThere's even a console reader, if the reason for unzipping is reading in the text terminal: https://github.com/wustho/epy https://github.com/wustho/epy
- JNRowe 6y agoemacs can be a surprisingly comfortable text mode epub reader too, via nov.el¹ which has been discussed here². If you use a GUI emacs build you get inline images and other goodies, but starting emacs with -nw can be a reasonable solution for quickly checking a book in a term. Note: You don't have to be a full-time emacs user to use nov.el. ¹ https://depp.brause.cc/nov.el/ https://depp.brause.cc/nov.el/ ² https://news.ycombinator.com/item?id=21426315 https://news.ycombinator.com/item?id=21426315
- ineedasername 6y agoIt actually goes deeper than that: Epub is basically a specific implementation of DocBook [0], which is itself a specific XML specification derived from the grand daddy of markup languages SGML. [0] https://en.wikipedia.org/wiki/DocBook https://en.wikipedia.org/wiki/DocBook
- Turing_Machine 6y agoIt's pretty easy to write code that generates and displays EPUB2. EPUB3 is a dog's breakfast -- it's hard to think of a better example of "second system effect". As far as I know, there's still not even one reference implementation that supports the full standard, even though it's been out for nearly 10 years. It gains you very little over EPUB2 for standard novels written in western scripts. EPUB3 is only needed if you require embedded scripting, support for non-alphabetical or bidirectional scripts, etc. I believe that most commercial "EPUB3" files still have an EPUB2 toc.ncx file and are designed to fall back to EPUB2 if the reader doesn't support EPUB3 (there are a lot of readers like this). Something that's easy to overlook: "The mimetype file must be a text document in ASCII that contains the string application/epub+zip. It must also be uncompressed, unencrypted, and the first file in the ZIP archive". All the other files in the ZIP can be compressed normally. What this means in practice is that uncompressing an EPUB is easy (just rename it to .zip, if necessary, and run unzip), but recompressing it requires some care. Assuming you've got your book's content in an OEBPS folder, and the container XML file in the META-INF folder, you can do it like this: zip -X0 test.epub mimetype zip -X9Dr test.epub META-INF OEBPS (edit to fix code formatting)
- BlueTemplar 6y agoWait, so what is the difference between .epub and .mhtml already ?
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- walton_simons 6y agoShoutout to some excellent software for ebook wrangling. The first is the "Standard Ebooks"[1] toolset, which is a suite of Python scripts to create, process, and build ebooks in all common formats. The results on the Standard Ebooks site speak for themselves. They're impeccable in every way, and far better than many big name, commercially produced efforts. GitHub: https://github.com/standardebooks/tools https://github.com/standardebooks/tools How to use: https://standardebooks.org/contribute/producing-an-ebook-step-by-step https://standardebooks.org/contribute/producing-an-ebook-ste... The second is Sigil, which is a great editor if you prefer to work with a GUI: GitHub: https://github.com/Sigil-Ebook/Sigil https://github.com/Sigil-Ebook/Sigil Homepage: https://sigil-ebook.com/about/ https://sigil-ebook.com/about/ [1] https://standardebooks.org/ https://standardebooks.org/
- ivan_ah 6y agoYes it's "just" HTML/CSS, but given the wide range of ePub reader capabilities, it's not like you can just take any web page and put it in an .epub. You have be conservative, and use only basic stuff. Also JavaScript is not supported by most ePub readers, so many of the modern web "dynamic" niceties are not available. For example, rendering math on the web has been a solved problem for many years thanks to MathJax and KaTeX, but these require JS, so cannot be used in ePubs (unless you know the reader supports scripting). If anyone is interested, I wrote a mega blog post about my journey to produce decent-looking math equations inside a ePub (and mobi files): https://minireference.com/blog/generating-epub-from-latex/ https://minireference.com/blog/generating-epub-from-latex/ some discussion from when I posted on HN https://news.ycombinator.com/item?id=26356903 https://news.ycombinator.com/item?id=26356903
- bobbylarrybobby 6y agoCouldn’t you just use KaTeX to compile to MathML ahead of time?
- ivan_ah 6y agoYeah, MathML is going to be the "right" way to do this in the long term, but right now not many reader devices support it, so not a viable option. I'm doing testing though, and hopefully going to see more MathML in the future (in browsers and ePub readers).
- salamandersauce 6y agoKobo's do. Apple iBooks does. PocketBooks Android app does (not sure about their readers though). Kindle's don't still. Which I feel is holding back it's use in books at least. It seems like with KFX they will at least convert MathML to images for publishers now? So hopefully that will lead publishers to use it. Out of all my epub math textbooks I have exactly one done with MathML and it's fucking glorious compared to the dogshit image based ones most publishers put out with blurry images intended for the 800x600 readers of 2007 and not modern 300 dpi ones. I had one book where literally 2/3rds of the equations were just missing from the file and unviewable on any device. This started on PAGE 7. I then had to ask the publisher to fix it, which they sort of did by replacing with a PDF version.
- garrickvanburen 6y agoIt’s so fun! I learned this a while back when I was deep in @font-face and web fonts and style sheets. I was almost immediately discouraged because, modern features like @font-face were inconsistently supported. Haven’t checked I a while now, maybe it’s better.
- codpiece 6y agoWhen I travel, I often put all my documents and PDFs on a Kobo. Easy to read, great battery life, barcodes display even when sleeping.
- rijoja 6y agoHad an amazon Kindle but it was practically useless for me due to how locked down it was. If I wanted to add something esoteric I had to mail it to amazon for whatever reason. I don't mind paying for book, but I would hate to have amazon decide what books I read. Is the kobo better in this regard?
- kcartlidge 6y ago- You can create an account to set up the device then never network-connect again - Shows as an external drive when connected via a micro-USB cable - Copy and paste books, then when you unplug from your laptop your Kobo sees them - With Calibre you can tag your books; tags become collections on-device - Understands more formats, but Calibre can also convert to EPUB during copying - You can also read the Adobe-DRM protected books (or ask Apprentice Alf)
- rijoja 6y agoThanks!
- rambojazz 6y agoWhat's going on with the link "wikipedia.org/wiki/EPUB#:~:text=EPUB%20is%20an%20e%2Dbook,smartphones%2C%20tablets%2C%20and%20computers."? There doesn't seem to be any ID in the page with that fragment.
- qwtel 6y agohttps://web.dev/text-fragments/#text-fragments https://web.dev/text-fragments/#text-fragments
- rijoja 6y agoHuh that is interesting. Well not just as it also includes MathML which isn't present in all modern browsers sadly.
- LordDragonfang 6y agoNot to sound egotistical, but did you learn that from a HN comment? Because I literally pointed that out to someone 4 days ago on here. https://news.ycombinator.com/item?id=26702559 https://news.ycombinator.com/item?id=26702559