SuttaCentral

Experimental epubs


#1

Our server can now generate epubs automatically, there is not yet a frontend for this feature but it is possible to build them manually. This is like a pre-release, for testing and feedback of the epubs.

If you just want to download some pre-generated epubs, here are the 4 Nikaya translations by @sujato
dn_en_sujato_908890.epub (315.1 KB)
mn_en_sujato_31df93.epub (576.3 KB)
sn_en_sujato_2ab6b8.epub (1.6 MB)
an_en_sujato_96aa80.epub (1.4 MB)

Generating epubs using the API

First you have to enter a URL like this (possibly in an incognito window):

https://staging.suttacentral.net/api/ebook/dn/en/sujato

That is the API endpoint, and after a few seconds it returns a JSON result that looks like this:

{"uid": "dn", "language": "en", "author": "sujato", "format": "epub", 
"href": "//staging.suttacentral.net/ebook/dn_en_sujato_e8d47d.epub"}

The href is a hyperlink to the generate epub, you need to put “https:” on the front or remove the leading //, and can then use it to download the epub.

https://staging.suttacentral.net/ebook/dn_en_sujato_e8d47d.epub

Please note that our frontend will tend to intercept these urls and if it does you’ll get a 404 error - this is because the API is not meant to be used manually. You can work around this by using an incognito window or command line tools like curl or wget to fetch these urls.

Details

The url form is: staging.suttacentral.net/api/ebook/{uid}/{lang}/{author}

In principle, you can enter any uid (division, subdivision, paṇṇāsa, sutta, vagga, whatever*), any language and any author, but unless you choose appropriately matching values you’ll get an empty book or possibly bizzare results. This system is designed to create epubs for our modern segmented texts in english/pali, but you can try your luck with legacy texts and other languages.

* I’m not sure how useful this feature will be. Maybe some people want to download single texts. Mainly it’s a feature because of how our data is structured.


Checkers needed for epub and kindle SN and AN
Where to download the full translation of the Pali canon?
#2

Sadhu Sadhu!

This is a wonderful development. Much gratitude to all who have helped make this possible.

There seems to be a problem with DN 6 on suttacentral itself. suttacentral.net/dn6/en/sujato There is some text at the top of the page that probably shouldn’t be there.

That may be what is causing this error when I open the file in sigil:

Cannot perform HTML updates since the file is not well formed: dn6.xhtml

When I run the epub check it gives this error for the dn6 file, line 11:

Can not nest a “p” tag inside another “p” tag. near column 216


#3

There is a problem with the table of contents with the AN book. Poor AN. It always has problems with those first chapters, doesn’t it. :slight_smile:

The first entry in the table of contents is for “Flaws.” This is the first sutta in the second chapter. Then the second item is for Perils and that links to the first sutta in the third chapter.

When I speak of the table of contents, I am talking about the semantic table of contents that is used by the rendering software. If you look at the toc.ncx you can see that the early suttas have items, they are just blank.

I can’t get the code to paste into this post, but if you look at the beginning of the toc.ncx you can see that there are entries where the text tags are blank.


#4

Looks like “Collection” is still part of the AN name.

Are there plans to organize the tables of contents in a structured, hierarchical way? As they are they are kind of unusable.

Another consideration would be to included the standard citation at the beginning of each sutta title so it was possible to do a search within the e-book. so you could have a sense of where you were in the book.

I’m guessing the TOC’s are a work in progress.

As I mentioned, I suggest making the titles on the cover larger so they work in Thumbnail mode.
image


#5

Indeed, the source PO file is malformed. @Blake, can you look into this? The segments are disordered, probably an issue with the msgctxt numbers?

Indeed, thanks for pointing this out. For some reason it is not picking up the translated titles for some suttas. Moreover, it is using stale data formats. See, eg. the third chapter, Akammaniya Vagga. This has the number AN 1.21–30//AN 1.3.1–10. But this hybrid system was used only on legacy SC, it is not part of our new system at all. We should ensure that all numbering, titles, and data, is pulled from the segmented text files themselves, not from elsewhere in the SC legacy data.


#6

Are you planning on making the table of contents hierarchical? At the very least it would be good if, for example, there could be 11 chapters as top level headings in the AN and a chapter for each samyutta in the SN. If there could be a level between each of those that would be great too.

Again, I am talking about the toc that the software/device would use to navigate, not a hard coded html toc.


#7

Ah! This explains so much. I kept getting 404.

Is the following API stable and supported indefinitely?
If so I can switch to using the SC REST api vs. Github translation.

https://suttacentral.net/api/suttas/mn1/sujato?lang=en

:pray:


#8

Yes, it is planned to improve the structure of the longer nikayas.

Note that it’s also possible to generate an epub for just a fraction of a nikaya, you can use a uid like sn-sagathavaggasamyutta to get SN1-11. Some of the nikayas are so long they become unwieldly in book form, usually when they come in dead-tree form they are split over multiple books.

I agree it would be better if the text takes up most the available space. Although it is a bit tricky because sometimes the titles can be pretty long, it’s easier to manually make the perfect cover than automatically. Ultimately @sujato is in charge of presentation.


#9

Yes. The basic structure of /api/ebook/{uid}/{lang}/{author} will remain, features might be added by query string parameters, for example at some point I’d like to think up some strategy for putting line-by-line view into book form, that might involve a parameter like “?line_by_line=ms”, meaning “use line-by-line view, with the ms edition as the alternate lines”. At the moment the only parameter is “debug” which pretty much dumps the contents of the ebook into the JSON response.


#10

Yes, that’s true. A large book is hard to hold and schlep around, but that’s not much of a factor with the ebook. As long as the toc is well structured, having a single volume is actually a benefit. When searching for a particular term, it is easier if a nikaya is a single file. And in terms of of library management on a device, it is much better to have a nikaya with a good toc as a single volume.

Yes, that was going through my mind as I made the mockup. I shudder to think of the hundreds of issues like this you have had to deal with. Perhaps for complete nikayas you could have a custom designed image. I am guessing that most people will go to your download page to get the the nikayas rather than generating their own.

Thanks again!


#11

misposted to wrong thread


#12

Yes, I’ll look into it at some point.


#13

I noticed that there is a chapter heading included at the top of an1.21. It seems to be ok on the website.

<div id="vagga">
  <section class="sutta" data-uid="an1.21" id="21"><div class="hgroup"><p class="division">Numbered Discourses 1</p>
<p>3. Useless</p>
<h1>21 </h1>
</div>

This part that has Numbered Discourses 1should not be there. Everywhere else it is only at the top of each chapter.


#14

So I just noticed in the e-book for AN, everything after 11:21 is blank. There are file, just nothing in them but an ellipses. And to my surprise… They are blank on the website too. Poor chapter 11. It’s like everyone gives up by the time they get there and stop reading. :frowning:
https://suttacentral.net/an11.22-29/en/sujato


#15

Aargh! Bloody Pootle! It seems to have chewed these up when we renamed the files. I will add this to the long list of “things to do to make Pootle work in a vaguely sane way while we try desperately to replace it”.


#16

So, I also noticed by chance that this sutta is missing in both the epub and the website.
https://suttacentral.net/an4.106
Should I be posting these to a different thread since they reflect a problem with the site itself?


#17

It’s not just us! Ven Bodhi has the note:

No text of this sutta occurs in any edition. The uddāna verse at the end of the vagga says: dve honti ambāni, “there are two [on] mangoes,” which is apparently why Be assigns the title. Mp says only, “The sixth is clear.” Both Ce and Be, referring to this comment, have a note: “The commentary says, ‘The sixth is clear,’ but it is not found in the canonical text.”

I’ll add a file noting this so we can avoid confusion in future.


#18

So I just generated an epub for the Questions of King Milinda translated by T.W. Rhys Davids.

It appears that the publication details is added to the end of each html file. It is enclosed in aside id=“metaarea” tags.

Here is the link to download what I generated: https://staging.suttacentral.net/api/ebook/mil/en/tw_rhysdavids

EDIT: I noticed that at the end of this page, https://suttacentral.net/mil5.1.10/en/tw_rhysdavids there is this text

Book 4 Chapter 2

In the epub file, this is marked up as <h3>. It is the only h3 in the doc.

EDIT2: Also noticed that there was text marked up as <p class="subdivision"> was inconsistent:

Book 1: The Secular Narrative
Book 2: The Distinguishing Characteristics of Ethical Qualities
Book 3: The Removal Of Difficulties
Book 4: The solving of dilemmas
Book 5
Book 6
Book 7: Similes of Arahatship
Book 8

So you can see that chapters 5, 6, and 8 don’t have actual names. Also Chapter 4 is not capitalized properly.


#19

@sujato, I just noticed that in the SN, the 56 Samyuttas don’t have English titles and are simply Linked Discourses 1–56. I think English titles are needed at a minimum, ideally with the Pali as well.

I know they are listed in Pali in the guide, but that part of the book is almost impossible to navigate on a reading device. The description of each samyutta seems to start with the English translation, but it seems like this should be coded in somehow.

If this is not an easy fix, I can fix it manually in the epub.


#20

Thanks for the feedback!

That’s right, this is our normal practice. If an EPUB consists of just one work, as in this case, then the notice should appear just once. But if an EPUB is combined from different sources, this starts to get complicated.

This is a mistake, thanks, I have fixed it:

This is how the text is structured, so it is not a mistake.

I will fix this in due course.

Yes, they really should. The way this is handled right now is not ideal (in fact it is not because of any policy or decision, it just flows from the manner in which our source text did things).

Until we improve this on the site, it would be best to extract the English titles from the blurbs.