1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-11-18 00:13:55 +01:00
crowbook/README.md

204 lines
6.7 KiB
Markdown
Raw Normal View History

2016-02-18 04:36:33 +01:00
Crowbook
========
[![Build Status](https://travis-ci.org/lise-henry/crowbook.svg?branch=master)](https://travis-ci.org/lise-henry/crowbook)
2016-02-21 18:28:48 +01:00
Render a markdown book in HTML, Epub or PDF.
2016-02-18 04:36:33 +01:00
2016-02-21 21:16:01 +01:00
Crowbook's purpose is to allow you to automatically generate multiple
outputs formats from a book written in Markdown. Its main focus is
novels, and the default settings should (hopefully) generate readables
book with correct typography.
2016-02-18 04:36:33 +01:00
2016-02-25 16:20:33 +01:00
Installing
----------
There are two ways to get `crowbook`: either use a precompiled binary
or build it yourself.
### Binaries ###
2016-02-21 18:28:48 +01:00
2016-02-26 19:23:06 +01:00
See [the releases page](https://github.com/lise-henry/crowbook/releases)
2016-02-25 16:20:33 +01:00
to download a precompiled binary for your architecture (currently:
Linux, Windows and MacOSX). Just extract the archive and run
2016-03-01 18:46:59 +01:00
`crowbook` (or `crowbook.exe` on Windows). You might also want to copy
the binary somewhere in your `PATH` for later usage.
2016-02-25 16:20:33 +01:00
### Building ###
You'll need to have the [Rust](https://www.rust-lang.org/) compiler
2016-02-21 18:28:48 +01:00
on your machine first; you can
[download and install it here](https://www.rust-lang.org/downloads.html). Once
it is down:
```
$ cargo install crowbook
```
2016-02-25 16:20:33 +01:00
will automatically download the latest `crowbook` release on
2016-02-26 19:23:06 +01:00
[crates.io](https://crates.io/crates/crowbook) and install it.
2016-02-21 18:28:48 +01:00
2016-02-19 23:01:34 +01:00
Usage
-----
2016-02-20 17:13:14 +01:00
The simplest command is:
```bash
$ crowbook <BOOK>
```
2016-02-25 16:20:33 +01:00
Where `BOOK` is a configuration file. Crowbook will then parse this
file and generate a book in HTML, Epub, LaTeX, and/or PDF,
according to the settings in the configuration file. So if you clone
2016-02-21 20:33:30 +01:00
this repository and run
```bash
$ crowbook book_example/config.book
```
2016-02-20 17:13:14 +01:00
2016-02-25 16:20:33 +01:00
you'll generate the example book in various formats. The
2016-02-21 20:33:30 +01:00
HTML version should look
[like that](http://lise-henry.github.io/crowbook/book.html).
2016-02-25 16:20:33 +01:00
To create a new book, assuming you have a
2016-02-21 20:33:30 +01:00
list of Markdown files, you can generate a template configuration file
with the `--create` argument:
```bash
$ crowbook --create my.book chapter_*.md
```
This will generate a default `my.book` file, which you'll need to complete.
This configuration file contains some metadata, options, and lists the
2016-02-20 17:13:14 +01:00
Markdown files. Here is a basic example:
2016-02-19 23:01:34 +01:00
```
2016-02-20 17:13:14 +01:00
author: Joan Doe
title: Some book
lang: en
output_html: some_book.html
+ chapter_1.md
+ chapter_2.md
+ chapter_3.md
+ ...
2016-02-19 23:01:34 +01:00
```
2016-02-20 17:13:14 +01:00
For more information see
2016-02-21 20:33:30 +01:00
[the configuration file page](book_example/config.md), or the whole
`book_example` source directory. (A (not necessarily
2016-02-21 20:33:30 +01:00
up-to-date) [rendered version is available in HTML here](http://lise-henry.github.io/crowbook/book.html)).
2016-02-20 17:13:14 +01:00
It is also possible to give additional parameters to `crowbook`;
2016-02-21 20:33:30 +01:00
we have already seen `--create`, but if you want the full list, see
[the arguments page](book_example/arguments.md).
2016-02-19 23:01:34 +01:00
2016-02-21 21:16:01 +01:00
Current features
----------------
### Output formats ###
Crowbook (to my knowledge) correctly supports HTML and EPUB (either
version 2 or 3) as output formats: rendered files should pass
respectively the [W3C validator](https://validator.w3.org/) and the
[IDPF EPUB validator](http://validator.idpf.org/) for a wide range of
(correctly Markdown formatted) input files. See the example book
rendered in [HTML](http://lise-henry.github.io/crowbook/book.html) and
[EPUB](http://lise-henry.github.io/crowbook/book.epub) on github.io.
2016-02-25 16:20:33 +01:00
LaTeX output is a bit more tricky: it should work reasonably well for
novels (the primary target of Crowbook), but `pdflatex` might occasionally
2016-03-01 18:46:59 +01:00
choke on some "weird" unicode character. Moreover, images are not yet
2016-02-25 20:11:06 +01:00
implemented (but should come soon). See the example book rendered in
[PDF](http://lise-henry.github.io/crowbook/book.pdf) on github.io.
2016-02-21 21:16:01 +01:00
ODT output is experimental at best. It might work if your inputs files
only include very basic formatting (basically, headers, emphasis and
bold), it will probably look ugly in the rest of the cases, and it
might miserably fail in some. See the example book rendered in
[ODT](http://lise-henry.github.io/crowbook/book.odt) on github.io if
you want to hurt your eyes.
### Input format ###
Crowbook uses
[pulldown-cmark](https://crates.io/crates/pulldown-cmark) and thus
2016-03-01 18:46:59 +01:00
should support most of CommonMark Markdown. Inline HTML, however, is
2016-02-23 23:51:21 +01:00
not implemented, and probably won't be, as the goal is to have books
2016-02-25 16:20:33 +01:00
that can also be generated in PDF (and maybe eventually ODT).
2016-02-21 21:16:01 +01:00
Maybe the most specific "feature" of Crowbook is that (by default, it
2016-02-25 16:20:33 +01:00
can be deactivated) it tries to "clean" the input files. By default this
2016-02-21 21:16:01 +01:00
doesn't do much (except removing superfluous spaces), but if the
book's language is set to french it tries to respect french
typography, replacing spaces with non-breaking ones when it is
appropriate (e.g. in french you are supposed to put a non-breaking
space before '?', '!', ';' or ':'). This feature is relatively limited
at the moment, but I might try to add more options and support for
more languages.
### Links handling ###
Crowbook tries to correctly translate local links in the input
Markdown files: e.g. if you have a link to a markdown file that is
part of your book, it will be transformed into a link inside the
document.
2016-02-19 23:01:34 +01:00
See also [Bugs](Bugs.md).
Acknowledgements
----------------
Besides the Rust compiler and standard library, Crowbook uses the
following libraries:
* [pulldown-cmark](https://crates.io/crates/pulldown-cmark) (for
parsing markdown)
2016-03-01 18:46:59 +01:00
* [yaml-rust](https://crates.io/crates/yaml-rust) (for parsing YAML blocks)
2016-02-20 18:41:02 +01:00
* [mustache](https://crates.io/crates/mustache) (for templating)
2016-02-20 17:24:07 +01:00
* [clap](https://github.com/kbknapp/clap-rs) (for parsing command line arguments)
2016-02-19 23:01:34 +01:00
* [chrono](https://crates.io/crates/chrono) (date and time library)
* [uuid](https://crates.io/crates/uuid) (to generate uuid)
2016-02-23 23:51:21 +01:00
It also uses configuration files from
2016-02-26 23:16:47 +01:00
[rust-everywhere](https://github.com/japaric/rust-everywhere) to use
[Travis]]https://travis-ci.org/) and
[Appveyor](http://www.appveyor.com/) to generate binaries for
2016-02-23 23:51:21 +01:00
various platforms on each release.
While Crowbook directly doesn't use them, there was also inspiration
from [Pandoc](http://pandoc.org/) and
[mdBook](https://github.com/azerupi/mdBook).
Also, the [W3C HTML validator](https://validator.w3.org/) and the
[IDPF EPUB validator](http://validator.idpf.org/) proved very useful
during development.
2016-02-19 23:01:34 +01:00
2016-02-21 18:28:48 +01:00
ChangeLog
---------
See [ChangeLog](ChangeLog.md).
Library
-------
While the main purpose of Crowbook is to be runned as a command line,
2016-02-25 16:20:33 +01:00
the code is written as a library, so if you want to build on it you can
2016-02-21 18:28:48 +01:00
use it as such. The code is currently badly documented (and badly in a
general manner), but you can look at the generated documentation [here](http://lise-henry.github.io/rust/crowbook/).
License
-------
2016-02-19 23:01:34 +01:00
2016-02-21 18:28:48 +01:00
Crowbook is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License (LGPL),
version 2.1 or (at your option) any ulterior version. See
[LICENSE](LICENSE.md) file for more information.
2016-02-23 23:51:21 +01:00