Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: provide epub download of The Book #20866

Closed
akavel opened this issue Jan 10, 2015 · 62 comments
Closed

doc: provide epub download of The Book #20866

akavel opened this issue Jan 10, 2015 · 62 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. P-low Low priority

Comments

@akavel
Copy link
Contributor

akavel commented Jan 10, 2015

Could you possibly add an .epub version of The Book for download on the website?

The epub format seems at least mentioned in some Makefiles, so I hope this should be not very hard -- unless it's defunct and unsupported, and would have to be done from scratch? If not, then still there are some tools like pandoc, that I think support making epubs from Markdown already, so at least should be doable without reinventing the tools...

I'd be very grateful, thanks.

@killercup
Copy link
Member

I've thought about this, as well. @steveklabnik, too.

Technically, this might a bit tricky, partially because of #20826.

What you need to do is create one markdown document with a correct outline (i.e. cleverly interpreting and changing headline levels) and in order of the table of contents (i.e. parsing the TOC file which is a markdown list containing links). But then it would be trivial to feed that to pandoc and generate all sorts of formats!

@akavel
Copy link
Contributor Author

akavel commented Jan 10, 2015

As to #20826, I've just sent a pull request that might (or might not) close the issue.

@killercup
Copy link
Member

@akavel I don't think that'll solve this problem by itself, since all the chapter headings are actually level two in the global table of contents.

E.g., "2.8. Compound Data Types" should be a level 2 heading in an ebook, therefore the content of that chapter should start headings at level 3. (In an epub/book, heading level 1 might be a "part", level 2 might be a "chapter" and level 3+ might be subsections.)

Your changes might simplify the script needed to compile the book contents though.

@killercup
Copy link
Member

@akavel @steveklabnik I created an epub version of the book!

@akavel
Copy link
Contributor Author

akavel commented Jan 11, 2015

Woohoo, awesome, thanks a lot! And the code samples seem to wordwrap quite nicely on my nook too, big thanks! :)

@kmcallister kmcallister added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-docs labels Jan 11, 2015
@Gankra
Copy link
Contributor

Gankra commented Jan 21, 2015

@killercup would it be possible to integrate this back into our toolchain for us to officially provide it?

@killercup
Copy link
Member

@gankro please do! Consider the code to be in the public domain; just take it, it's yours.

I don't think it'd take much time to rewrite this in Rust, it's just a bunch of calls to pandoc. It would be a nice feature for rustbook.

@sanxiyn sanxiyn removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 6, 2015
@killercup
Copy link
Member

Just an update: Last week I redid most of that script I posted above. This now also deals with normalizing code blocks and fixing links. You can find it here and the results (html, epub, pdf) here.

@steveklabnik
Copy link
Member

Further update: I am still interested in getting this done, but takes some infrastructure work. @brson and @edunham and I should chat about it, maybe.

@asolove
Copy link

asolove commented Jan 11, 2016

Working on a general way to do this in https://github.com/azerupi/mdBook/issues/88.

In the meantime, a rust book-specific version is probably as simple as:

pandoc -S -o book.epub {list of markdown files in the order they should be included}`.

@brson
Copy link
Contributor

brson commented Jan 11, 2016

It's not too difficult to make one of our doc builders produce the epub files and for us to publish it. The big wart here though is that we produce doc packages for every platform we publish, so every builder needs pandoc in order to keep them at parity.

One thing we might do in the interim is to make epub artifacts opt-in, set up pandoc on our linux builder only (the one that we use to publish the docs to the website). Then we would be publishing the epubs, but e.g. the mac doc packages wouldn't contain it.

Incidentally, splittiing non-api docs out of the repo would (with a lot of other work) fix this problem since we could build all the docs on linux.

@okulev
Copy link

okulev commented Mar 26, 2016

@killercup doesn't generate epubs anymore :-( So I made a script that generates proper Table Of Contents:

#!/bin/sh

if [ ! -d "$1" ]; then
    echo Usage: $(basename "$0") BOOKDIR \> trpl.md
    echo Then: pandoc -S -o trpl.epub trpl.md
    exit 1
fi

cat "$1/README.md"
echo

grep '^ *\*' "$1/SUMMARY.md" |
sed 's/^\*/main/g' |
sed 's/^ \+\*/sub/g' |
sed 's/\[.*\](\(.*\))/\1/g' |
while read level filename; do
    cat "$1/$filename" |
    if [ "$level" = "main" ]; then
        sed 's/^\(#\+ \)/#\1/g' |
        sed 's/^% /# /g'
    else
        sed 's/^\(#\+ \)/##\1/g' |
        sed 's/^% /## /g'
    fi |
    sed 's/^\(```rust\),.*$/\1/g'
    echo
done

@pravic
Copy link
Contributor

pravic commented May 31, 2016

@killercup doesn't generate epubs anymore :-(

@okulev, but you can find it in PRs as I did.

@brson brson added the P-low Low priority label Aug 22, 2016
@edunham
Copy link
Member

edunham commented Aug 22, 2016

Help wanted: Write a .travis.yml to do this build on Travis and upload it to GitHub's releases storage. (ping me for help if this is confusing)

@edunham edunham added the E-help-wanted Call for participation: Help is requested to fix this issue. label Aug 22, 2016
@bkoehm
Copy link

bkoehm commented Mar 3, 2017

Script from @okulev worked nicely for me, so +1 for that.
I wanted a PDF instead of an EPUB so I added this step:

ebook-convert trpl.epub trpl.pdf \
  --margin-top 36 --margin-bottom 36 \
  --margin-left 36 --margin-right 36

ebook-convert is from Calibre.

I tried ebook-convert directly on the md instead of epub and it produced a PDF, but the resulting PDF is better if you use pandoc to convert it to epub first.

pandoc may be able to convert directly to PDF without ebook-convert, but I got errors from pandoc about unrecognized unicode characters. ("Unicode char" ... "not set up for use with LaTeX".) That's probably fixable for someone that knows more about pandoc and LaTeX than I do.

EDIT: I got pandoc PDF conversion working. No need for ebook-convert.
The trick was adding the --latex-engine=xelatex option. i.e., pandoc --latex-engine=xelatex -V geometry:margin=0.5in -V fontsize=12pt -o /tmp/trpl.pdf /tmp/trpl.md. And the quality of this output is superior compared to my previously described attempts.

@pravic
Copy link
Contributor

pravic commented Apr 3, 2017

Any download links to the recent book versions?

@codingHahn
Copy link

@killercup 's repo works, but the files need to be updated. @killercup how would I do this?

@DevQps
Copy link
Contributor

DevQps commented Aug 9, 2019

@jasonwilliams That would be great! Let us know if there's any progress! (Y)

@jasonwilliams
Copy link
Member

jasonwilliams commented Aug 13, 2019

@DevQps
There is progress, and you can help!
See rust-lang/mdBook#1000
Test it out and give feedback, there are instructions in the PR

@kaizhang16
Copy link

kaizhang16 commented Oct 14, 2019

Hello everyone, I have generated the epub and pdf version by pandoc inspired by #20866 (comment). And here is the links:

Hope it helps.

@antoneliasson
Copy link

Hello everyone, I have generated the epub and pdf version by pandoc inspired by #20866 (comment). And here is the links:

* https://github.com/kaizhang91/book/blob/feature-epub-and-pdf/assets/The-Rust-Programming-Language-2019-10-13.epub

* https://github.com/kaizhang91/book/blob/feature-epub-and-pdf/assets/The-Rust-Programming-Language-2019-10-13.pdf

Hope it helps.

Thanks for generating the offline ebooks! Your epub lacks the "ferrises" in the code boxes and some words are hyphenated in strange ways, but otherwise it looks great and is perfectly usable! I've so far enjoyed about the first quarter of it.

The PDF on the other hand has a few major problems. Some code boxes are completely missing content (e.g. page 22, pages 74-80). In at least one place a big chunk of text is missing. Some of it has not compiled properly and is shown as a compressed super long line of TeX code (page 29).

An epub rendering is what I wanted the most though, so thanks again for that!

@kaizhang16
Copy link

kaizhang16 commented Jan 10, 2020

@antoneliasson Thank you for your detailed bug report! I'm very happy to hear about that the offline book is helpful. However, let me clarify some points:

  • the epub version:
    • It does not lack "ferrises". It's true that they aren't shown on duokan or iReader, but they are shown on calibre. So the bug is related to the capacity of epub reader for rendering some css syntax.
    • Actually, image and code block are also not supported by some epub reader
  • the pdf version:
    • As you kindly explained, there are some serious bugs in 2019-10-13 version, so I create 2019-10-17 version
    • In 2019-10-17 version, I have solved code box bug. And I think it's true for page 22, pages 74-80, etc.
    • In 2019-10-17 version, there are still some super long lines. This bug is related to breaklines doesn't work with \mintinline when other options are set gpoore/minted#194. Maybe I have no time to fix it recently.
    • I will change above link to 2019-10-17 version instead of 2019-10-13 version.

In fact, I have read through the 2019-10-17 pdf version instead of the 2019-10-13 epub version. 😃 Maybe some serious bugs you most care about have already been fixed. Give it a try if you're interested in the pdf version someday. 😉

@jasonwilliams
Copy link
Member

jasonwilliams commented Feb 25, 2020

Help Needed!

rust-lang/mdBook#1000 seems to be working pretty well from what i can see so far, I just need some feedback now. The PR allows the rust book to be read offline, new changes will still take affect.

You can just navigate to https://jason-williams.co.uk/book/ and try it out, then leave any feedback in the issue above.

@Sjord
Copy link

Sjord commented Jun 30, 2021

I recently used mdbook-epub to build an epub version of several mdbooks, and this worked reasonably well.

@shirshak55
Copy link
Contributor

shirshak55 commented Jan 8, 2022

For pdf:
https://github.com/shirshak55/Rust-Book-In-PDF/releases

I update the pdf every day via ci so it should be somewhat better :) Also, sorry I myself never use mobi so don't have any incentives to do it.

@vitali2y
Copy link

vitali2y commented Jan 8, 2022

Letting you know that .epub version of the Book would be nice to have here.

@peterbartha
Copy link

Latest DIY steps for converting (any) Rust learning material to EPUB (or other ebook formats).
Steps and required files: https://gist.github.com/peterbartha/54708ae739478a45b52612311d49717c

Samples:
image

image

@vitali2y
Copy link

Latest DIY steps for converting (any) Rust learning material to EPUB (or other ebook formats). Steps and required files: https://gist.github.com/peterbartha/54708ae739478a45b52612311d49717c

What are principal improvements in comparison with ~3 years old receipt?

@peterbartha
Copy link

Latest DIY steps for converting (any) Rust learning material to EPUB (or other ebook formats). Steps and required files: https://gist.github.com/peterbartha/54708ae739478a45b52612311d49717c

What are principal improvements in comparison with ~3 years old receipt?

The following:

  1. More readable source code (previously problems with nested <pre> tags, and pandoc optimizations),
  2. Clickable "Table of Contents" section added,
  3. Code legend (Ferris) is present (instead of removing from the samples),
  4. Handle unsupported HTML tags (i.e. <details>),
  5. (Optional) Consistent stylesheet for the ebook.

@johnroyer
Copy link

The file below, published at 2022-01-13, is convert via Epubor. Download if you need.

https://s3.ap-northeast-1.amazonaws.com/assets.blog.zeroplex.tw/2022/2022-01-13-The-Rust-Programming-Language.epub

@zhoukuncheng
Copy link

This browser extension can convert HTML to EPUB easily.
https://github.com/dteviot/WebToEpub

@anzbert
Copy link

anzbert commented Aug 7, 2022

thx @CeresCa .
I've used that extension to create create an epub for the latest book version
The_Rust_Programming_Language_1.59.epub.zip

@miguno
Copy link

miguno commented Jan 10, 2023

@peterbartha's instructions (https://gist.github.com/peterbartha/54708ae739478a45b52612311d49717c) worked for me. Thanks!

@lapwat
Copy link

lapwat commented Jan 23, 2023

You can easily create the ebook yourself with papeer. It keeps content, text formatting, images and code blocks.

Install it with: go install github.com/lapwat/papeer@latest

Use the CSS selector ol>li>a to select all table of content items. Specify epub format.

papeer get --selector='ol>li>a' --format=epub https://doc.rust-lang.org/book/
# [===========>] The Rust Programming Language - The Rust Programming Language (104 / 104)
# Ebook saved to "The_Rust_Programming_Language_-_The_Rust_Programming_Language.epub"

The_Rust_Programming_Language_-_The_Rust_Programming_Language.epub.zip

@ivanglushko
Copy link

ivanglushko commented May 25, 2023

Here's a pdf print from the site - And I manually added table of contents there.

The Rust Programming Language.pdf

@vitali2y
Copy link

Here's a pdf print from the site - And I manually added table of contents there.

Cool. How about .epub as on title on the top?

@impredicative
Copy link

impredicative commented May 29, 2023

Here's a pdf print from the site - And I manually added table of contents there.

The Rust Programming Language.pdf

How does one go about finding such a link for a future version?

@shirshak55
Copy link
Contributor

@impredicative if you are seeking pdf then you can find it here. Updated daily. https://github.com/shirshak55/Rust-Book-In-PDF/releases

@hustcer
Copy link

hustcer commented Jun 1, 2023

@shirshak55 Wow, super cool, It would be better if there were a epub version

@ivanglushko
Copy link

ivanglushko commented Jun 1, 2023

How does one go about finding such a link for a future version?

I don't plan on keeping this up to date sorry. Maybe it's possible to write a script that will link all the chapters in pdf but I didn't find a fast solution. So had to do it manually.

@dralley
Copy link
Contributor

dralley commented Sep 4, 2023

This is a duplicate of rust-lang/book#3669 - in any case, book related issues should be filed over there.

@Dylan-DPC
Copy link
Member

Closing this as the book issue already covers this

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2023
@dieterplex
Copy link

Like shirshak55's daily PDF https://github.com/shirshak55/Rust-Book-In-PDF/releases,
here's my daily ePub https://dieterplex.github.io/rust-ebookshelf/ in case someone is still interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. P-low Low priority
Projects
None yet
Development

No branches or pull requests