Giter Club home page Giter Club logo

mdbook-epub's Introduction

MDBook EPUB Backend

  • Build Status
  • Build status
  • Rust

(Rendered Docs)

An experimental backend to mdbook which will render your document as an EPUB file, suitable for viewing on e-readers and other similar devices.

WARNING: Not yet production ready. May eat your laundry.

Note: At the moment the default stylesheet is quite bare bones, serving mainly to reset the styling used on various devices back to a known default. This default isn't overly pretty, so you may want to include your own stylesheets.

Getting Started

Before you can use the EPUB backend, you'll need to actually install it:

$ cargo install mdbook-epub

Next you need to let mdbook know to use the alternate renderer by updating your book.toml file. This is done by simply adding an empty output.epub table.

[book]
title = "mdBook Documentation"
description = "Create book from markdown files. Like Gitbook but implemented in Rust"
author = "Mathieu David"

[output.html]
mathjax-support = true

+ [output.epub]

Now everything is set up, just run mdbook as normal and the output directory (book/epub/ by default) should now contain an extra file called mdBook Documentation.epub (substituting in whatever your book's title is).

The mdbook-epub executable can be run in "standalone" mode. This is where the backend can be used without needing to be called by mdbook, useful if you only want to render the EPUB document.

$ mdbook-epub -s true ./path/to/book/dir
$ mdbook-epub --standalone true ./path/to/book/dir

Configuration

Configuration is fairly bare bones at the moment.

Recognized options:

additional-css: A list of paths to CSS stylesheets to include.

use-default-css: Controls whether to include the default stylesheet.

cover-image: A path to a cover image file for the ebook.

additional-resources: A list of path to files which should be added to the EPUB, such as typefaces. They will be added with path OEBPS/<filename>.

no-section-label: In the contents list, don't prefix the chapter title with its section number.

curly-quotes: Enable converting straight quotes 'x' and "x" to ‘x’ and “x” (aka smart quotes).

[output.epub]
additional-css = ["./path/to/main.css"]
use-default-css = false
cover-image = "ebook-cover.png"
additional-resources = ["./assets/Open-Sans-Regular.ttf"]
no-section-label = true
curly-quotes = true

Planned Features

The following features are planned (a checked box indicates it's complete). This list is by no means complete, so feature requests are most welcome!

  • Make a valid EPUB file with the bare chapter contents
  • Generate a basic TOC
  • Nested chapters - currently they're all inserted at the top level
  • Include a default CSS stylesheet (master.css)
    • Actually make that stylesheet pretty enough for human consumption
  • Include user-defined stylesheets and themes
  • Allow users to tweak the generated page by providing their own template
  • Ensure the generated document is viewable on the following platforms
    • Amazon Kindle
    • Sony PRS-T3

Contributing

This backend is still very much in the development phase and as such a large number of features are missing. If you think of something you'd like please create an issue on the issue tracker!

mdbook-epub's People

Contributors

blandger avatar dieterplex avatar dluschan avatar glatavento avatar michael-f-bryan avatar rams3s avatar simsilver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdbook-epub's Issues

corrupt

Building on arch linux and macOS results in corrupt .epub.
llpp renders the .epub but only the page headers show.

epub-builder fails to build

mdbook-epub's epub-builder dependency fails to build, causing mdbook-epub to fail to build. The error message is:

   Compiling epub-builder v0.3.0
error[E0283]: type annotations required: cannot resolve `std::string::String: std::convert::AsRef<_>`
   --> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/epub-builder-0.3.0/src/epub.rs:207:74
    |
207 |         self.toc.add(TocElement::new("toc.xhtml", self.metadata.toc_name.as_ref()));
    |                                                                          ^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0283`.
error: Could not compile `epub-builder`.

I tried it on both stable 1.36.0 and nightly 1.38.0 installed via rustup on debian 10.

Thoughts about migrating to Github Actions

Recently I found travis-ci build status badge in README is missing. The link of the badge is no longer valid and seems moved to https://app.travis-ci.com/github/Michael-F-Bryan/mdbook-epub long time ago. Last build in that page is 2 years ago and the banner urge you to update the price plan. If we are going to keep useing travis-ci, I guess we need to request Travis CI OSS plan by @Michael-F-Bryan. Then there will be credits per month could be used. Or we should consider other better free lunch.

In my mind, one is AppVeyor currently used and the popular one, Github Actions. But I'm not familiar with AppVeyor to comment its pros & cons. Currently CI with AppVeyor only run on Windows platform that could be a point to improve . I do think there would be more contributors familiar to Github Actions and have better support for processes like binary releasing and crates.io publishing in place. If it is a low hanging fruit, why don't we move forward?

Error: Summary parsing failed

When trying to compile The Rust Async Book, it gives me a Summary Parsing Failed Error.

$ mdbook-epub --standalone async-book
Error: Summary parsing failed

I tried running this in both the root directory and the source directory.

Required to downgrade mdbook to 0.3.7

mdbook-epub is awesome by the way! :)

I followed install instructions and added the epub entry to the master (commit bfe1ab96d717d1dda50e499b360f2e2f57e1750a) of nomicon:

+[output.epub]

Then ran:

 ~/Desktop/dev/nomicon   master ●  mdbook build
2020-07-03 08:32:02 [INFO] (mdbook::book): Book building has started
2020-07-03 08:32:02 [INFO] (mdbook::book): Running the epub backend
2020-07-03 08:32:02 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Incompatible mdbook version, expected 0.3.7 but got 0.4.0
2020-07-03 08:32:02 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2020-07-03 08:32:02 [ERROR] (mdbook::utils): Error: Rendering failed
2020-07-03 08:32:02 [ERROR] (mdbook::utils): 	Caused By: The "epub" renderer failed
$ mdbook --version
mdbook v0.4.0

Downgrading:

$ cargo uninstall mdbook
$ cargo install mdbook --version 0.3.7
$ mdbook build
2020-07-03 08:51:39 [INFO] (mdbook::book): Book building has started
2020-07-03 08:51:39 [INFO] (mdbook::book): Running the epub backend
2020-07-03 08:51:39 [INFO] (mdbook::renderer): Invoking the "epub" renderer
2020-07-03 08:51:39 [INFO] (mdbook::book): Running the html backend

Success!

Parsing external links as local

I'm trying to turn the rust webassembly book into an epub. I added the necessary line to book.toml, ran mdbook build and got the following:

2019-08-13 12:53:33 [INFO] (mdbook::book): Book building has started
2019-08-13 12:53:33 [INFO] (mdbook::book): Running the epub backend
2019-08-13 12:53:33 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Inspecting the book for additional assets failed
        Caused By: Unable to fetch the canonical path for /home/tom/downloads/wasmbook/src/game-of-life/https://upload.wikimedia.org/wikipedia/commons/e/e5/Gospers_glider_gun.gif
        Caused By: No such file or directory (os error 2)
2019-08-13 12:53:33 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2019-08-13 12:53:33 [ERROR] (mdbook::utils): Error: Rendering failed
2019-08-13 12:53:33 [ERROR] (mdbook::utils):    Caused By: The "epub" renderer failed

It looks like it considers that external link to be a local file

install break down in Windows

I's using rust-msvc channel to install and haven't install CMAKE:

--- stderr
fatal: Not a git repository (or any of the parent directories): .git
thread 'main' panicked at '
failed to execute command: 系统找不到指定的文件。 (os error 2)
is `cmake` not installed?

build script failed, must exit now', C:\Users\34937\.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\cmake-0.1.29\src\lib.rs:632:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

#rustdoc_include does not work

Building the "The Rust Programming Language" book from master results in many {{#rustdoc_include path}} listings not being included. I'm not clear on where this comes from, since it works in mdbook.

Incompatible mdbook version, expected 0.3.7 but got 0.4.13

2021-12-11 09:34:39 [INFO] (mdbook::book): Book building has started
2021-12-11 09:34:39 [INFO] (mdbook::book): Running the epub backend
2021-12-11 09:34:39 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Incompatible mdbook version, expected 0.3.7 but got 0.4.13
2021-12-11 09:34:40 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2021-12-11 09:34:40 [ERROR] (mdbook::utils): Error: Rendering failed
2021-12-11 09:34:40 [ERROR] (mdbook::utils):    Caused By: The "epub" renderer failed

HTML files are not valid

Generated HTML files inside epub file are not valid. They don't have DOCTYPE, nor required tags. I generated books with intent to read them in KOReader, and it cannot load them. Calibre book reader, or okular are more forgiving.

Below sample of few first lines of HTML document from generated ‘Rust by Example’ epub:

<h1>Rust by Example</h1>
<p><a href="https://www.rust-lang.org/">Rust</a> is a modern systems programming language focusing on safety, speed,
and concurrency. It accomplishes these goals by being memory safe without using 
garbage collection.</p>

Using mdbook-epub version 0.3.0.

mdbook-epub finishes but resulting epub seems empty (although all content is in there).

The mdbook at https://gitlab.com/sspaeth/survival-manual (viewable as online mdbook at https://sspaeth.gitlab.io/survival-manual
seems to be successfully parsed by mdbook-epub -s and a resulting epub file is created (attached, just renamed the .epub to .zip otherwise github refuses to upload it). However, when I load it in fbreader, or any other epub viewer, it seems either empty or leads to infinite spinners. So something seems wrong with the epub file.
I know too little about the epub structure to be able to know what went wrong there.

rename back to .epub:
SurvivalManual.zip
.

can't install because compiling libssh2-sys failed

out log in the console window:

error: failed to run custom build command for libssh2-sys v0.2.6
process didn't exit successfully: E:\Test\mdbook-epub-0.1.0\target\release\build\libssh2-sys-054ac8fbde399b72\build-script-build (exit code: 101)
--- stdout
running: "cmake" "C:\Users\ljd\.cargo\registry\src\github.com-1ecc6299db9ec823\libssh2-sys-0.2.6\libssh2" "-G" "Visual Studio 15 2017 Win64" "-DCRYPTO_BACKEND=WinCNG" "-DZLIB_INCLUDE_DIR=E:\Test\mdbook-epub-0.1.0\target\release\build\libz-sys-f137a425f38f13de\out/include" "-DBUILD_SHARED_LIBS=OFF" "-DENABLE_ZLIB_COMPRESSION=ON" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTING=OFF" "-DCMAKE_INSTALL_PREFIX=E:\Test\mdbook-epub-0.1.0\target\release\build\libssh2-sys-1872c162ac6e8a5f\out" "-DCMAKE_C_FLAGS= /nologo /MD" "-DCMAKE_C_FLAGS_RELEASE= /nologo /MD" "-DCMAKE_CXX_FLAGS= /nologo /MD" "-DCMAKE_CXX_FLAGS_RELEASE= /nologo /MD" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is unknown
-- Configuring incomplete, errors occurred!
See also "E:/Test/mdbook-epub-0.1.0/target/release/build/libssh2-sys-1872c162ac6e8a5f/out/build/CMakeFiles/CMakeOutput.log".
See also "E:/Test/mdbook-epub-0.1.0/target/release/build/libssh2-sys-1872c162ac6e8a5f/out/build/CMakeFiles/CMakeError.log".

--- stderr
fatal: Not a git repository (or any of the parent directories): .git
CMake Error at CMakeLists.txt:40 (project):
No CMAKE_C_COMPILER could be found.

thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', C:\Users\ljd.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.29\src\lib.rs:632:5
note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile mdbook-epub v0.1.0 (E:\Test\mdbook-epub-0.1.0), intermediate artifacts can be found at E:\Test\mdbook-epub-0.1.0\target

Caused by:
build failed

how to use mdbook Preprocessors

The generated epub file still contains {{ #rustdoc_include }} tags, it seems that the default preprocessors do not work. I tried it with the newest released version and the main brunch, both don't work.

links: Expands the {{ #playground }}, {{ #include }}, and {{ #rustdoc_include }} handlebars helpers in a chapter to include the contents of a file. See Including files for more.

can't compile

Hello, I just encountered an error when I install it:

error[E0616]: field `sections` of struct `mdbook::book::Book` is private
  --> .cargo/git/checkouts/mdbook-epub-bd1aa49df9dbc8c0/2d567f4/src/generator.rs:71:22
   |
71 |         for item in &self.ctx.book.sections {
   |                      ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

I use rustc 1.23.0 in Ubuntu 16.04. What should I do? Thanks!

Does the plugin support mathjax?

I'm in love with mdbook and always write something with math formula in markdown, And I want to make this thing to be published as epub files. However, I found out that the mathjax support for mdbook is output.html only. Does anyone have the same requirement to display math in their epubs ?

The integration_tests don't pass

The tests don't pass:

cargo test
...
thread 'output_epub_is_valid' panicked at 'called `Result::unwrap()` on an `Err` value: EpubCheck', tests/integration_tests.rs:79:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
...

got problem

PS E:\Test\rustbook> mdbook build
2019-03-15 16:39:46 [WARN] (mdbook::book): It appears you are still using book.json for configuration.
2019-03-15 16:39:46 [WARN] (mdbook::book): This format is no longer used, so you should migrate to the
2019-03-15 16:39:46 [WARN] (mdbook::book): book.toml format.
2019-03-15 16:39:46 [WARN] (mdbook::book): Check the user guide for migration information:
2019-03-15 16:39:46 [WARN] (mdbook::book): https://rust-lang-nursery.github.io/mdBook/format/config.html
2019-03-15 16:39:49 [INFO] (mdbook::book): Book building has started
2019-03-15 16:39:49 [INFO] (mdbook::book): Running the epub backend
2019-03-15 16:39:49 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Inspecting the book for additional assets failed
Caused By: Unable to fetch the canonical path for \?\E:\Test\rustbook\src\img/trpl20-01.png
Caused By: 文件名、目录名或卷标语法不正确。 (os error 123)
2019-03-15 16:39:49 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2019-03-15 16:39:49 [ERROR] (mdbook::utils): Error: Rendering failed
2019-03-15 16:39:49 [ERROR] (mdbook::utils): Caused By: The "epub" renderer failed

Problem (bug?) with path canonicalization on Windows

I tried building TRPL on Windows after adding [output.epub] as a renderer to its book.toml.
It crashes with the following error:

Z:\Projects\rust-lang\book\2018-edition>mdbook build
2018-08-11 12:14:04 [INFO] (mdbook::book): Book building has started
2018-08-11 12:14:04 [INFO] (mdbook::book): Running the epub backend
2018-08-11 12:14:04 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Inspecting the book for additional assets failed
        Caused By: Unable to fetch the canonical path for \\?\Z:\Projects\rust-lang\book\2018-edition\src\img/trpl20-01.png
        Caused By: The filename, directory name, or volume label syntax is incorrect. (os error 123)2018-08-11 12:14:05 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2018-08-11 12:14:05 [ERROR] (mdbook::utils): Error: Rendering failed
2018-08-11 12:14:05 [ERROR] (mdbook::utils):    Caused By: The "epub" renderer failed

You'll note the following:

  1. The resource file is specified as ![hello from rust](img/trpl20-01.png) in the markdown file.
  2. The path specified in the error message starts with \\?\. As stated in Microsoft's documentation:

File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections.

I'm quite new to Rust and thus not sure how where the responsibility falls design-wise (path library or user code), but the regular mdbook renderer works fine, so I'm filing this here.

New Maintainer Needed

I haven't needed to generate EPUBs for ages, so haven't had a real incentive to continue developing it or resolve open issues/PRs. If you use this tool or would like to see it improved, let me know and we can sort something out.

Some points for future work:

  • Create a good default template which emits full HTML documents (will probably fix the myriad of "book is corrupted" issues - see #31, #29, #23, #20, #28, and the solution in #28 (comment))
  • Create a good default stylesheet
  • Allow people to link to the web (issue: #22, proposed solution: #25)
  • Make sure this tool can be used to consistently render The Rust Programming Language
  • Publish pre-compiled binaries for Windows/Linux/Mac using GitHub Releases
  • Make sure building with the --standalone flag will go through the normal mdbook rendering process (#30)

`cargo install mdbook-epub` is broken

When I run cargo install mdbook-epub I get this compile error:

   Compiling mdbook-epub v0.4.31
error[E0277]: `?` couldn't convert the error to `Error`
  --> /Users/njn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-epub-0.4.31/src/config.rs:34:63
   |
34 |                 let mut cfg: Config = table.clone().try_into()?;
   |                                                               ^ the trait `From<toml::de::Error>` is not implemented for `Error`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the following other types implement trait `From<T>`:
             <Error as From<SemVerError>>
             <Error as From<ReqParseError>>
             <Error as From<Box<ureq::Error>>>
             <Error as From<epub_builder::Error>>
             <Error as From<mdbook::errors::Error>>
             <Error as From<ureq::Error>>
             <Error as From<RenderError>>
             <Error as From<toml::de::Error>>
             <Error as From<std::io::Error>>
   = note: required for `Result<config::Config, Error>` to implement `FromResidual<Result<Infallible, toml::de::Error>>`

I see this with rust 1.71 and nightly 1.73.

This caused CI breakage for me here: https://github.com/nnethercote/perf-book/actions/runs/5572424446/jobs/10178452751. I will have to disable the epub build for the Rust perf-book because of this :(

Error: Unable to parse RenderContext

I'm trying to run this on the ESP book: https://github.com/esp-rs/book. mdbook builds and runs it without issue.

$ mdbook --version
mdbook v0.4.15
$ mdbook-epub --version
mdbook-epub 0.3.0

$ mdbook build
2022-01-21 16:14:12 [INFO] (mdbook::book): Book building has started
2022-01-21 16:14:13 [INFO] (mdbook::book): Running the html backend
$ mdbook serve # works fine

After adding [output.epub] to book.toml...

$ mdbook build
2022-01-21 16:14:32 [INFO] (mdbook::book): Book building has started
2022-01-21 16:14:32 [INFO] (mdbook::book): Running the epub backend
2022-01-21 16:14:32 [INFO] (mdbook::renderer): Invoking the "epub" renderer
Error: Unable to parse RenderContext
        Caused By: invalid type: null, expected path string at line 1 column 30427
2022-01-21 16:14:32 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2022-01-21 16:14:32 [ERROR] (mdbook::utils): Error: Rendering failed
2022-01-21 16:14:32 [ERROR] (mdbook::utils):    Caused By: The "epub" renderer failed

$ mdbook-epub --standalone ./src
Error: Couldn't open SUMMARY.md
$ mdbook-epub --standalone .
Error: Summary parsing failed

I don't see any --verbose flags to point me to the issue; unclear to me in what file line 1 column 30427 might be *. Please let me know if I can provide more information, and thank you for a useful tool!

EDIT: * I don't see any obvious issues with SUMMARY.md, and other markdown viewers on my system seem to render it without difficulty. It clearly doesn't have 30k columns on line 1, so I'm thinking it might not be the issue.

cargo install --git https://github.com/Michael-F-Bryan/mdbook-epub fail

Trying to build mdbook-epub with cargo install --git https://github.com/Michael-F-Bryan/mdbook-epub fails with on rust 1.23 stable and a current nightly. This is the rather horrible backtrace.

Compiling mdbook-epub v0.1.0 (https://github.com/Michael-F-Bryan/mdbook-epub#5b444da8)
error: failed to compile `mdbook-epub v0.1.0 (https://github.com/Michael-F-Bryan/mdbook-epub#5b444da8)`, intermediate artifacts can be found at `/tmp/cargo-install.C4WymtNdieyg`

Caused by:
failed to run custom build command for `mdbook-epub v0.1.0 (https://github.com/Michael-F-Bryan/mdbook-epub#5b444da8)`
process didn't exit successfully: `/tmp/cargo-install.C4WymtNdieyg/release/build/mdbook-epub-3c752ec9cfd69cb7/build-script-build` (exit code: 101)
--- stderr
    Updating git repository `https://github.com/Michael-F-Bryan/mdbook`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CargoError(Msg("failed to load source for a dependency on `mdbook`"), State { next_error: Some(CargoError(Msg("Unable to update https://github.com/Michael-F-Bryan/mdbook?branch=alternate_backends#95682e35"), State { next_error: Some(CargoError(Internal(Git(Error { code: -3, klass: 4, message: "revspec \'95682e35b678c0233a92813636fbe745abed9cb9\' not found" })), State { next_error: None, backtrace: Some(stack backtrace:
0:     0x5614d4b5697c - backtrace::backtrace::trace::hba410d46ab87232a
1:     0x5614d4b56032 - backtrace::capture::Backtrace::new::hdbe2e64f3483be34
2:     0x5614d4b55c19 - error_chain::make_backtrace::h93dcac2a14613e38
3:     0x5614d4b55ca4 - <error_chain::State as core::default::Default>::default::h231554e29efa3e79
4:     0x5614d483bbcb - cargo::sources::git::utils::GitDatabase::rev_for::h6c4583f7ab879d1f
5:     0x5614d48a0c35 - <cargo::sources::git::source::GitSource<'cfg> as cargo::core::source::Source>::update::h4653ab0b4485eb35
6:     0x5614d4861b8a - _ZN5cargo4core8registry15PackageRegistry13ensure_loaded17h2b4179525e162ddbE.llvm.B02F815C
7:     0x5614d4862df0 - <cargo::core::registry::PackageRegistry<'cfg> as cargo::core::registry::Registry>::query::h1aed3afdef95ffe0
8:     0x5614d498071d - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once::hb535c4c09677b882
9:     0x5614d4999400 - <&'a mut I as core::iter::iterator::Iterator>::next::h9f93af2c9914ce8a
10:     0x5614d4909c0d - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h000cbd71b6902401
11:     0x5614d498c78c - cargo::core::resolver::activate::heac4b486623a68db
12:     0x5614d498d3d9 - cargo::core::resolver::activate_deps_loop::h2686b2ff33d99060
13:     0x5614d49897ef - cargo::core::resolver::resolve::ha5139123f09474fe
14:     0x5614d48f3386 - cargo::ops::resolve::resolve_with_previous::h11e89d59a073c2f8
15:     0x5614d48f255e - cargo::ops::resolve::resolve_with_registry::h8b17509cdba1840f
16:     0x5614d48f2365 - cargo::ops::resolve::resolve_ws::hdce30565a6810cc3
17:     0x5614d481f383 - build_script_build::main::h7d4460492e054357
18:     0x5614d481bab2 - std::rt::lang_start::{{closure}}::hc22b0797250aa3ef
19:     0x5614d4b64f47 - std::rt::lang_start_internal::{{closure}}::h62834cbd79274432
                        at /checkout/src/libstd/rt.rs:59
                        - std::panicking::try::do_call::hadce92951ff7cc53
                        at /checkout/src/libstd/panicking.rs:480
20:     0x5614d4b86c0e - __rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:101
21:     0x5614d4b6c355 - std::panicking::try::h3997a39b1b7fdce8
                        at /checkout/src/libstd/panicking.rs:459
                        - std::panic::catch_unwind::h50a0951778ee5a7c
                        at /checkout/src/libstd/panic.rs:365
                        - std::rt::lang_start_internal::hcab36a357ecdf5ab
                        at /checkout/src/libstd/rt.rs:58
22:     0x5614d481fae3 - main
23:     0x7fb1d1e451c0 - __libc_start_main
24:     0x5614d481b079 - _start
25:                0x0 - <unknown>) })), backtrace: Some(stack backtrace:
0:     0x5614d4b5697c - backtrace::backtrace::trace::hba410d46ab87232a
1:     0x5614d4b56032 - backtrace::capture::Backtrace::new::hdbe2e64f3483be34
2:     0x5614d4b55c19 - error_chain::make_backtrace::h93dcac2a14613e38
3:     0x5614d4b55ca4 - <error_chain::State as core::default::Default>::default::h231554e29efa3e79
4:     0x5614d483bbcb - cargo::sources::git::utils::GitDatabase::rev_for::h6c4583f7ab879d1f
5:     0x5614d48a0c35 - <cargo::sources::git::source::GitSource<'cfg> as cargo::core::source::Source>::update::h4653ab0b4485eb35
6:     0x5614d4861b8a - _ZN5cargo4core8registry15PackageRegistry13ensure_loaded17h2b4179525e162ddbE.llvm.B02F815C
7:     0x5614d4862df0 - <cargo::core::registry::PackageRegistry<'cfg> as cargo::core::registry::Registry>::query::h1aed3afdef95ffe0
8:     0x5614d498071d - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once::hb535c4c09677b882
9:     0x5614d4999400 - <&'a mut I as core::iter::iterator::Iterator>::next::h9f93af2c9914ce8a
10:     0x5614d4909c0d - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h000cbd71b6902401
11:     0x5614d498c78c - cargo::core::resolver::activate::heac4b486623a68db
12:     0x5614d498d3d9 - cargo::core::resolver::activate_deps_loop::h2686b2ff33d99060
13:     0x5614d49897ef - cargo::core::resolver::resolve::ha5139123f09474fe
14:     0x5614d48f3386 - cargo::ops::resolve::resolve_with_previous::h11e89d59a073c2f8
15:     0x5614d48f255e - cargo::ops::resolve::resolve_with_registry::h8b17509cdba1840f
16:     0x5614d48f2365 - cargo::ops::resolve::resolve_ws::hdce30565a6810cc3
17:     0x5614d481f383 - build_script_build::main::h7d4460492e054357
18:     0x5614d481bab2 - std::rt::lang_start::{{closure}}::hc22b0797250aa3ef
19:     0x5614d4b64f47 - std::rt::lang_start_internal::{{closure}}::h62834cbd79274432
                        at /checkout/src/libstd/rt.rs:59
                        - std::panicking::try::do_call::hadce92951ff7cc53
                        at /checkout/src/libstd/panicking.rs:480
20:     0x5614d4b86c0e - __rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:101
21:     0x5614d4b6c355 - std::panicking::try::h3997a39b1b7fdce8
                        at /checkout/src/libstd/panicking.rs:459
                        - std::panic::catch_unwind::h50a0951778ee5a7c
                        at /checkout/src/libstd/panic.rs:365
                        - std::rt::lang_start_internal::hcab36a357ecdf5ab
                        at /checkout/src/libstd/rt.rs:58
22:     0x5614d481fae3 - main
23:     0x7fb1d1e451c0 - __libc_start_main
24:     0x5614d481b079 - _start
25:                0x0 - <unknown>) })), backtrace: Some(stack backtrace:
0:     0x5614d4b5697c - backtrace::backtrace::trace::hba410d46ab87232a
1:     0x5614d4b56032 - backtrace::capture::Backtrace::new::hdbe2e64f3483be34
2:     0x5614d4b55c19 - error_chain::make_backtrace::h93dcac2a14613e38
3:     0x5614d4b55ca4 - <error_chain::State as core::default::Default>::default::h231554e29efa3e79
4:     0x5614d483bbcb - cargo::sources::git::utils::GitDatabase::rev_for::h6c4583f7ab879d1f
5:     0x5614d48a0c35 - <cargo::sources::git::source::GitSource<'cfg> as cargo::core::source::Source>::update::h4653ab0b4485eb35
6:     0x5614d4861b8a - _ZN5cargo4core8registry15PackageRegistry13ensure_loaded17h2b4179525e162ddbE.llvm.B02F815C
7:     0x5614d4862df0 - <cargo::core::registry::PackageRegistry<'cfg> as cargo::core::registry::Registry>::query::h1aed3afdef95ffe0
8:     0x5614d498071d - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once::hb535c4c09677b882
9:     0x5614d4999400 - <&'a mut I as core::iter::iterator::Iterator>::next::h9f93af2c9914ce8a
10:     0x5614d4909c0d - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h000cbd71b6902401
11:     0x5614d498c78c - cargo::core::resolver::activate::heac4b486623a68db
12:     0x5614d498d3d9 - cargo::core::resolver::activate_deps_loop::h2686b2ff33d99060
13:     0x5614d49897ef - cargo::core::resolver::resolve::ha5139123f09474fe
14:     0x5614d48f3386 - cargo::ops::resolve::resolve_with_previous::h11e89d59a073c2f8
15:     0x5614d48f255e - cargo::ops::resolve::resolve_with_registry::h8b17509cdba1840f
16:     0x5614d48f2365 - cargo::ops::resolve::resolve_ws::hdce30565a6810cc3
17:     0x5614d481f383 - build_script_build::main::h7d4460492e054357
18:     0x5614d481bab2 - std::rt::lang_start::{{closure}}::hc22b0797250aa3ef
19:     0x5614d4b64f47 - std::rt::lang_start_internal::{{closure}}::h62834cbd79274432
                        at /checkout/src/libstd/rt.rs:59
                        - std::panicking::try::do_call::hadce92951ff7cc53
                        at /checkout/src/libstd/panicking.rs:480
20:     0x5614d4b86c0e - __rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:101
21:     0x5614d4b6c355 - std::panicking::try::h3997a39b1b7fdce8
                        at /checkout/src/libstd/panicking.rs:459
                        - std::panic::catch_unwind::h50a0951778ee5a7c
                        at /checkout/src/libstd/panic.rs:365
                        - std::rt::lang_start_internal::hcab36a357ecdf5ab
                        at /checkout/src/libstd/rt.rs:58
22:     0x5614d481fae3 - main
23:     0x7fb1d1e451c0 - __libc_start_main
24:     0x5614d481b079 - _start
25:                0x0 - <unknown>) })', /checkout/src/libcore/result.rs:916:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
            at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
            at /checkout/src/libstd/sys_common/backtrace.rs:68
            at /checkout/src/libstd/sys_common/backtrace.rs:57
2: std::panicking::default_hook::{{closure}}
            at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
            at /checkout/src/libstd/panicking.rs:397
4: std::panicking::rust_panic_with_hook
            at /checkout/src/libstd/panicking.rs:577
5: std::panicking::begin_panic
            at /checkout/src/libstd/panicking.rs:538
6: std::panicking::begin_panic_fmt
            at /checkout/src/libstd/panicking.rs:522
7: rust_begin_unwind
            at /checkout/src/libstd/panicking.rs:498
8: core::panicking::panic_fmt
            at /checkout/src/libcore/panicking.rs:71
9: core::result::unwrap_failed
10: build_script_build::main
11: std::rt::lang_start::{{closure}}
12: std::panicking::try::do_call
            at /checkout/src/libstd/rt.rs:59
            at /checkout/src/libstd/panicking.rs:480
13: __rust_maybe_catch_panic
            at /checkout/src/libpanic_unwind/lib.rs:101
14: std::rt::lang_start_internal
            at /checkout/src/libstd/panicking.rs:459
            at /checkout/src/libstd/panic.rs:365
            at /checkout/src/libstd/rt.rs:58
15: main
16: __libc_start_main
17: _start

error[E0597]: `local_ctx` does not live long enough

error[E0597]: `local_ctx` does not live long enough
   --> /root/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mdbook-0.3.7/src/renderer/html_handlebars/helpers/navigation.rs:155:25
    |
155 |             t.render(r, &local_ctx, &mut local_rc, out)
    |                         ^^^^^^^^^^ borrowed value does not live long enough
156 |         })?;
    |         -
    |         |
    |         `local_ctx` dropped here while still borrowed
    |         borrow might be used here, when `local_rc` is dropped and runs the destructor for type `handlebars::RenderContext<'_, '_>`
    |
    = note: values in a scope are dropped in the opposite order they are defined

For more information about this error, try `rustc --explain E0597`.
error: could not compile `mdbook` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `mdbook-epub v0.3.0`, intermediate artifacts can be found at `/tmp/cargo-installeVRNpc`

Impossible to open on Kobo Glo e-reader

I made an epub out of the rust book using mdbook-epub. However, my e-reader refuses to open it saying that (translated to english):
Your reader isn't allowed to open this book. This book is protected by Adobe Digital Rights Management (DRM). You need to confirm access to your reader using your Adobe ID by using Adobe Digital Editions (ADE). Please read kobo.com/help for more informations.

The book was transfered using Calibre on Ubuntu, and Calibre reads it with no problem. Other books transfered with Calibre work fine.

Licensing inconsistency between Cargo.toml, License, Dependencies

The LICENSE file specifies that this crate uses MPL, while the Cargo.toml specifies that it uses MIT, which is what shows up on crates.io. In addition, this crate partially depends on the epub crate, which is GPL, so I suspect there may be a possibility that the entire crate might need to be licensed under GPL.

EPUB files are missing images

Thanks for your work.

I have generated an epub from the latest sources of the 'Rust Programming Language', but the generated EPUB is missing images.

Am I doing something wrong? Or is this feature missing at the moment?

markdown tables do not render as tables

Reduction file:

# Chapter 1

|test|test2|
|----|-----|
|cool|neato|

Expected:

The epub renderer renders tables mostly consistently with the HTML one, which looks something like this:
screenshot-localhost_3000-2019 12 07-19_38_11

Actual:

The epub renderer outputs the plain text with no processing. Something like this:

|test|test2| |----|-----| |cool|neato|

Additional Information:

  • manually putting in table tags instead does correctly render tables, so I suspect this is just turning on additional preprocessor
  • I'm using Calibre on linux as the reader for testing
  • I'd be open to submitting code if you can point me in the direction of it (and will forgive a novice rust programmer)

release a binary on github

This is such a great addon to the (great) mdbook.
Thank you for your work.
Would it be possible to release it as a binary ? At least compiled for x86_64.
It would make it much easier to release this as a precompiled package for arch linux and other distros. It would make much easier for people who dont have the entire rust distribution to quickly try it out.

Epub result not readable on a Sony PRS-T3.

I'm testing to build the The Rustonomicon for use on my Sony PRS-T3. Sadly the resulting .epub in not readable. I ran it through calibre (epub -> epub conversion) and the result is readable and quite good. I've tried a few links and they work. ToC works etc. The pictures do not work for some reason but all in all it's quite useable!

I started looking into why the .epub generated by mdbook-epub does not work right away, and I think I know why.

Running epubcheck on the result gives a lot of errors like this:

ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/README.html(1,5): Error while parsing file 'elements from namespace "" are not allowed'.
FATAL(RSC-016): book/epub/The Rustonomicon.epub/OEBPS/README.html(2,2): Fatal Error while parsing file 'The markup in the document following the root element must be well-formed.'.
ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/README.html(-1,-1): Error while parsing file 'The markup in the document following the root element must be well-formed.'.
ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/meet-safe-and-unsafe.html(1,5): Error while parsing file 'elements from namespace "" are not allowed'.
FATAL(RSC-016): book/epub/The Rustonomicon.epub/OEBPS/meet-safe-and-unsafe.html(2,2): Fatal Error while parsing file 'The markup in the document following the root element must be well-formed.'.

If I compare the result of mdbook-epub with that which has went through calibre I noticed all .html files lack a xml header.

Here's what mdbook-epub generates:

<h1>The Rustonomicon</h1>
<h4>The Dark Arts of Advanced and Unsafe Rust Programming</h4>
<h1>NOTE: This is a draft document that discusses several unstable aspects of Rust, and may contain serious errors or outdated information.</h1>
<blockquote>
<p>Instead of the programs I had hoped for, there came only a shuddering blackness
... and lots more ...

This is what calibre generates:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Unknown</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link href="../stylesheet.css" rel="stylesheet" type="text/css"/>
<link href="../page_styles.css" rel="stylesheet" type="text/css"/>
</head>
  <body class="calibre"><h1 class="calibre1">The Rustonomicon</h1>
<h4 class="calibre2">The Dark Arts of Advanced and Unsafe Rust Programming</h4>
<h1 class="calibre1">NOTE: This is a draft document that discusses several unstable aspects of Rust, and may contain serious errors or outdated information.</h1>
<blockquote class="calibre3">
<p class="calibre4">Instead of the programs I had hoped for, there came only a shuddering blackness
... and lots more...
</body></html>

Anyway considering the output is good when ran through calibre, I think this project is quite close to be really useful! I have a Nook Simple Touch and a Sony PRS-T3 and am willing to help test this project with those devices if you want.

feature request: pop-up footnotes

It is possible to show a pop-up instead of jumping to the note when clicking on footnotes 1 in the calibre reader and also on Kindles (Paperwhite & Oasis confirmed by me).
As far as I can tell this behaviour is due to the links containing two attributes like so:
<a class="noteref" epub:type="noteref" href=.....>1</a>

That is much more useful than jumping to, say, the end of the document.
So, in case it is simple to include those two attributes in footnotes, I would highly appreciate it.
They don't seem to bother other readers.

Footnotes

  1. such as this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.