mirror of
https://github.com/lise-henry/crowbook
synced 2024-04-18 19:24:03 +02:00
Fix: Remove trailing whitespace
This commit is contained in:
parent
83a9d4359c
commit
0134ee3922
78
ChangeLog.md
78
ChangeLog.md
|
@ -12,7 +12,7 @@ unreleased
|
|||
* Description lists
|
||||
* Strikethrough
|
||||
* Task items
|
||||
* New option:
|
||||
* New option:
|
||||
* `crowbook.files_mean_chapters` allow to enforce that each files
|
||||
means a chapter break or to make sure that it doesn't (by default,
|
||||
only true for numbered chapters).
|
||||
|
@ -28,7 +28,7 @@ unreleased
|
|||
0.14.1 (2018-06-01)
|
||||
-------------------
|
||||
* `--stats` can now display more statistics when used with the
|
||||
`--verbose` option (if support for advanced statistics is compiled)
|
||||
`--verbose` option (if support for advanced statistics is compiled)
|
||||
* LaTeX outputs now make uses of user-defined `rendering.chapter` and
|
||||
`rendering.part`
|
||||
* Dependencies update
|
||||
|
@ -67,16 +67,16 @@ unreleased
|
|||
* The `template.tex` template was quite modified. Crowbook now
|
||||
uses custom command for most markdown elements, defined in the
|
||||
template. This allow an user to redefine the way the book is
|
||||
rendered without having to modify Crowbook itself. Unfortunately,
|
||||
as tex templates for previous Crowbook versions won't work anymore.
|
||||
rendered without having to modify Crowbook itself. Unfortunately,
|
||||
as tex templates for previous Crowbook versions won't work anymore.
|
||||
* the `resources.files` option is now a YAML list of strings, instead of a
|
||||
comma-seprated string.
|
||||
comma-seprated string.
|
||||
* Add support for grammalecte grammar checker.
|
||||
* `crowbook` command takes a new argument, `-S` or `--stats` which
|
||||
displays stats on the book (currently, words and characters count).
|
||||
* Interactive fiction:
|
||||
* Added conditional blocks.
|
||||
* Options:
|
||||
* Options:
|
||||
* `output.xxx` options can now take the "auto" value, which will infer the
|
||||
output file name based on the book file name.
|
||||
* `output` is a new option that can specify a series of format to
|
||||
|
@ -103,7 +103,7 @@ unreleased
|
|||
This release includes a few new features, such as the possiblity to
|
||||
include Markdown files as section/subsections and not only as chapter,
|
||||
experimental support for superscript and subscript, and yet more
|
||||
experimental support for writing interactive fiction.
|
||||
experimental support for writing interactive fiction.
|
||||
|
||||
* Book configuration file:
|
||||
* It is now possible to include subchapters using the `--` command
|
||||
|
@ -151,7 +151,7 @@ experimental support for writing interactive fiction.
|
|||
where HTML code is not appropriate. Templates can use this
|
||||
metadata with the `foo_raw` value.
|
||||
* HTML/EPUB: fix double-escaping/rendering issues in titles.
|
||||
* EPUB:
|
||||
* EPUB:
|
||||
* Escape title and author before feeding them to epub-builder.
|
||||
* Fix content.opf issue by not rendering first
|
||||
chapter's title (marked as beginning of document) in `<guide>`.
|
||||
|
@ -179,7 +179,7 @@ experimental support for writing interactive fiction.
|
|||
|
||||
0.11.2 (2017-03-05)
|
||||
-----------------------
|
||||
* General:
|
||||
* General:
|
||||
* When there is an error setting an option from the book configuration
|
||||
file (e.g. because it is an invalid key), print an error but do not
|
||||
abort, only ignore this specific option.
|
||||
|
@ -198,7 +198,7 @@ experimental support for writing interactive fiction.
|
|||
* `[syntect](https://crates.io/crates/syntect)` is now the default
|
||||
for `rendering.highlight`. Concretely, this means that by default
|
||||
syntax highlighting is now done when `crowbook` is run instead of
|
||||
using `[highlight.js](https://highlightjs.org/)`.
|
||||
using `[highlight.js](https://highlightjs.org/)`.
|
||||
* EPUB:
|
||||
* Now sets the "cover-image" property and meta so readers should
|
||||
display cover correctly.
|
||||
|
@ -217,7 +217,7 @@ experimental support for writing interactive fiction.
|
|||
is not used.
|
||||
* Avoid creating an empty file if some book renderer fails
|
||||
(e.g. EPUB or ODT because `zip` command is not present).
|
||||
|
||||
|
||||
|
||||
0.11.1 (2017-01-05)
|
||||
-----------------------
|
||||
|
@ -260,10 +260,10 @@ support for parts!
|
|||
substantial options renaming (see below).
|
||||
* Crowbook now supports parts (above the "chapter" level), using the
|
||||
'@' character in the book configuration file.
|
||||
* Command-line interface:
|
||||
* Command-line interface:
|
||||
* Behaviour of `--to` should now be consistent for all output
|
||||
formats.
|
||||
* If `--output` is set to `-`, prints to stdout.
|
||||
* If `--output` is set to `-`, prints to stdout.
|
||||
* Conversely, if `<BOOK>` is set to `-`, reads from stdin.
|
||||
* Path specified by `--output` is now interpreted relatively to
|
||||
current directory (and not depending on where `<BOOK>` is or its
|
||||
|
@ -310,7 +310,7 @@ support for parts!
|
|||
([#23](https://github.com/lise-henry/crowbook/issues/23)).
|
||||
* Fix "previous chapter" links that were not displayed when
|
||||
"html.header" was set.
|
||||
* HTML:
|
||||
* HTML:
|
||||
* Fix the way initial letter is displayed if `rendering.initials`
|
||||
is true.
|
||||
* Internationalization:
|
||||
|
@ -324,7 +324,7 @@ support for parts!
|
|||
the LaTeX class (must be 10, 11 or 12).
|
||||
* `tex.title` can be set to `false` to avoid rendering the title
|
||||
with `\maketitle`.
|
||||
* `tex.paper_size` specifies the paper size for PDF output.
|
||||
* `tex.paper_size` specifies the paper size for PDF output.
|
||||
* `tex.template.add`, `html.css.add` and `epub.css.add`allow to
|
||||
specify inline LaTex or CSS code in the book configuration file
|
||||
that will be added respectively to `tex.template.add`,
|
||||
|
@ -341,13 +341,13 @@ support for parts!
|
|||
-----------------------
|
||||
* Building:
|
||||
* Crowbook now requires rustc >= 1.13.0 to build.
|
||||
* Pre-built binaries now all include the proofreading feature.
|
||||
* Pre-built binaries now all include the proofreading feature.
|
||||
* Linux binaries are now linked against `musl` library so they
|
||||
should really work on any Linux platform.
|
||||
* Bugfixes:
|
||||
* Fixed escaping of `author` and `title` fields.
|
||||
* Fixed text cleaning in ODT rendering that causes corrupt files to
|
||||
be generated.
|
||||
be generated.
|
||||
* CommandLine Interface:
|
||||
* Crowbook displays clearer error messages when unable to launch
|
||||
`latex` or `zip` commands.
|
||||
|
@ -384,16 +384,16 @@ Fixed a bug in `fr.po` translation that prevented building from fresh install.
|
|||
This release contains some breaking changes (mostly for the API, which has been split in separate libraries). It alse features some internationalization support, and
|
||||
the program should now be tranlated if your `LANG` environment
|
||||
variable is set to french.
|
||||
* **Breaking changes**:
|
||||
* **Breaking changes**:
|
||||
* Templates:
|
||||
* Conditional inclusion depending on `lang` must now be done using `lang_LANG` (e.g.
|
||||
`lang_fr`, `lang_en`, and so on). This might impact custom `epub.css` and `html.css`
|
||||
templates.
|
||||
* Conditional inclusion depending on `lang` must now be done using `lang_LANG` (e.g.
|
||||
`lang_fr`, `lang_en`, and so on). This might impact custom `epub.css` and `html.css`
|
||||
templates.
|
||||
* API:
|
||||
* The `escape` module has been moved to a separate crate,
|
||||
`crowbook_text_processing`. The `cleaner` module is no longer
|
||||
public, but the features it provided are also available in
|
||||
`crowbook_text_processing`.
|
||||
`crowbook_text_processing`.
|
||||
* New options:
|
||||
* `html.css.colors` allows to provide a CSS file that only redefine
|
||||
the colour scheme. Such a file can be built from `crowbook
|
||||
|
@ -432,21 +432,21 @@ experimental.
|
|||
* `proofread.nb_spaces`, if set to true, highlights non-breaking spaces so it is
|
||||
easier to check the correct typography of a book. Note that it
|
||||
requires that `html.escape_nb_spaces` be set to true (default) to
|
||||
work.
|
||||
work.
|
||||
* `proofread.reppetitions`, if set to true, uses
|
||||
[Caribon](https://github.com/lise-henry/caribon) to highlight
|
||||
repetitions in a document. It also uses the settings `proofread.repetitions.fuzzy`,
|
||||
`proofread.repetitions.max_distance`,
|
||||
`proofread.repetitions.threshold`,
|
||||
`proofread.repetitions.threshold`,
|
||||
`proofread.repetitions.fuzzy.threshold`,
|
||||
`proofread.repetitions.ignore_proper`. Note that this feature
|
||||
is not built by default, you'll have to build crowbook with
|
||||
`cargo build --release --features "repetitions"`.
|
||||
* New default settings for options:
|
||||
* `tex.command` is now `xelatex` by default.
|
||||
* `tex.command` is now `xelatex` by default.
|
||||
* Rendering:
|
||||
* LaTeX:
|
||||
* Add support for xelatex in the default template.
|
||||
* Add support for xelatex in the default template.
|
||||
* Improved french cleaner (see [an article (in french)](https://crowdagger.github.io/textes/articles/heuristique.html)
|
||||
that talks about what it does).
|
||||
* Crowbook user guide: documentation has been updated to correctly
|
||||
|
@ -504,7 +504,7 @@ More detailed changes for this release:
|
|||
* `output.base_path` specifies a directory where the output files (set
|
||||
by `output.FORMAT` will be written.
|
||||
* `resources.base_path.templates` specifies where templates can be
|
||||
found.
|
||||
found.
|
||||
* Rendering:
|
||||
* Metadata can now contain Markdown and will be rendered by the
|
||||
renderers. This might not be a good idea for common fields
|
||||
|
@ -522,7 +522,7 @@ More detailed changes for this release:
|
|||
* If `tex.class` is set to `article`, chapters will be displayed as
|
||||
`\sections` since `article` class doesn't handle chapters.
|
||||
* Except if `tex.class` is set to `book`, margins are now
|
||||
symmetrical.
|
||||
symmetrical.
|
||||
* LaTex template now uses `version` and `date`.
|
||||
* Bugfixes:
|
||||
* `import_config` only import options from another book file that
|
||||
|
@ -530,7 +530,7 @@ More detailed changes for this release:
|
|||
set by the caller. E.g., `author: foo` then `import_config:
|
||||
bar.book` won't erase the author previously set.
|
||||
* `import_config` now correctly translates the imported book's
|
||||
paths.
|
||||
paths.
|
||||
* Crowbook program:
|
||||
* Still working to improve error messages.
|
||||
* `crowbook --list-options` uses colors. This might hurt your eyes.
|
||||
|
@ -540,7 +540,7 @@ More detailed changes for this release:
|
|||
* Added static methods to `Logger` to allows displaying messages
|
||||
more easily/prettily.
|
||||
* Reduce pubic API's surface so less changes will need to be
|
||||
considered breaking in the future.
|
||||
considered breaking in the future.
|
||||
|
||||
0.8.0 (2016-09-19)
|
||||
------------------
|
||||
|
@ -642,7 +642,7 @@ paragraph or inside a paragraph.
|
|||
* Fixed rendering of lists when `lang` is set to `fr`.
|
||||
* Links are now HTML-escaped, fixing errors in XHTML (for EPUB
|
||||
rendering) when links contained '&' character.
|
||||
|
||||
|
||||
|
||||
0.5.1 (2016-04-14)
|
||||
------------------
|
||||
|
@ -717,7 +717,7 @@ Mostly rendering fixes:
|
|||
files will be placed in a `data` directory in the EPUB.
|
||||
* Rendering:
|
||||
* Templates can now use localized strings according to the `lang`
|
||||
option
|
||||
option
|
||||
* Standalone HTML now includes locale files using base64.
|
||||
* Standalone HTML displays one chapter at a time, thouht it can be
|
||||
changed via a button in the menu.
|
||||
|
@ -768,7 +768,7 @@ displayed:
|
|||
different colors.
|
||||
* Bugfixes:
|
||||
* Crowbook no longer crashes when called with the `--to` argument
|
||||
if it can't create a file.
|
||||
if it can't create a file.
|
||||
|
||||
|
||||
0.3.0 (2016-02-27)
|
||||
|
@ -787,7 +787,7 @@ displayed:
|
|||
* More modules and methods are now private.
|
||||
* Improved documentation.
|
||||
* Added more unit tests.
|
||||
* Bugfixes:
|
||||
* Bugfixes:
|
||||
* Epub renderer now correctly renders unnumbered chapter without a
|
||||
number in its toc.ncx file
|
||||
|
||||
|
@ -808,13 +808,13 @@ displayed:
|
|||
* Latex: makes what is possible to avoid orverflowing the page.
|
||||
* Minor changes:
|
||||
* Latex: improvement of the default way URLs are displayed.
|
||||
|
||||
|
||||
0.2.0 (2016-02-25)
|
||||
|
||||
0.2.0 (2016-02-25)
|
||||
------------------
|
||||
* Command line arguments:
|
||||
* New argument `--print-template` now allows to print a built-in
|
||||
template to stdout.
|
||||
template to stdout.
|
||||
* New argument `--list-options` prints out all valid
|
||||
options in a config file (or in `set`), their type and default
|
||||
value.
|
||||
|
@ -825,14 +825,14 @@ displayed:
|
|||
* Configuration file:
|
||||
* Added support for multiline strings in `.book` files, with
|
||||
either '|' (preserving line returns) or '>' (transforming line
|
||||
returns in spaces)
|
||||
returns in spaces)
|
||||
* New option `display_toc` allows to display the table of contents
|
||||
(whose name, at least for HTML, is specified by `toc_name`) in
|
||||
HTML and PDF documents.
|
||||
* Option `numbering` now takes an int instead of a boolean,
|
||||
allowing to specify the maximum level to number (e.g. `1`:
|
||||
chapters only, `2`: chapters and sectino, ..., `6`: everything).
|
||||
* Rendering:
|
||||
* Rendering:
|
||||
* Added support for numbering all headers, not just level-1 (e.g.,
|
||||
having a subsection numbered `2.3.1`).
|
||||
* Tables and Footnotes are now implemented for HTML/Epub and LaTeX
|
||||
|
|
20
README.md
20
README.md
|
@ -5,7 +5,7 @@
|
|||
|
||||
Crowbook's aim is to allow you to write a book in Markdown without worrying about formatting or typography, and let the program generate HTML, PDF and EPUB output for you.
|
||||
Its focus is novels and fiction, and the default settings should (hopefully) generate readable books with correct typography without requiring you to worry about it.
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
To see what Crowbook's output looks like, you can read the Crowbook guide rendered in
|
||||
|
@ -33,7 +33,7 @@ Just extract the archive and run `crowbook`
|
|||
You might also want to copy the binary somewhere in your `PATH` for later usage.
|
||||
|
||||
If you are on Debian GNU/Linux or Ubuntu (on a PC architecture), you can also download `.deb` packages on
|
||||
[the releases page](https://github.com/lise-henry/crowbook/releases).
|
||||
[the releases page](https://github.com/lise-henry/crowbook/releases).
|
||||
|
||||
### Using Cargo
|
||||
|
||||
|
@ -43,7 +43,7 @@ the package manager for
|
|||
[Rust](https://www.rust-lang.org/).
|
||||
You can
|
||||
[install it here](https://www.rust-lang.org/downloads.html).
|
||||
Once that is done:
|
||||
Once that is done:
|
||||
|
||||
```bash
|
||||
$ cargo install crowbook
|
||||
|
@ -75,7 +75,7 @@ $ crowbook <BOOK>
|
|||
```
|
||||
|
||||
where `BOOK` is a configuration file.
|
||||
Crowbook will parse this file and generate HTML, EPUB, and/or PDF output formats, according to the settings in the configuration file.
|
||||
Crowbook will parse this file and generate HTML, EPUB, and/or PDF output formats, according to the settings in the configuration file.
|
||||
|
||||
To create a new book, assuming you have a list of Markdown files, you can generate a template configuration file with the `--create` argument:
|
||||
|
||||
|
@ -84,7 +84,7 @@ $ crowbook my.book --create 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 Markdown files.
|
||||
This configuration file contains some metadata, options, and lists the Markdown files.
|
||||
|
||||
For short books containing only a single Markdown file, it is possible to embed some metadata at the beginning of the file and use the `--single` or `-s` option to run `crowbook` directly on this Markdown file and avoid creating a separate book configuration file:
|
||||
|
||||
|
@ -133,7 +133,7 @@ e.g. if you have a link to a Markdown file that is part of your book, it will be
|
|||
|
||||
### Inline YAML blocks
|
||||
|
||||
Crowbook supports inline YAML blocks:
|
||||
Crowbook supports inline YAML blocks:
|
||||
|
||||
```yaml
|
||||
---
|
||||
|
@ -148,7 +148,7 @@ This is mostly useful when Crowbook is run with the `--single` argument (receivi
|
|||
|
||||
Crowbook can also generate "proofreading" copies in HTML or PDF, highlighting grammar errors and repetitions.
|
||||
For more information, see
|
||||
[the proofreading chapter of the guide](guide/proofreading.md).
|
||||
[the proofreading chapter of the guide](guide/proofreading.md).
|
||||
|
||||
### Interactive fiction
|
||||
|
||||
|
@ -240,15 +240,15 @@ Note that, in order to facilitate code reuse, some features have been split to s
|
|||
* [epub-builder](https://github.com/lise-henry/epub-builder)
|
||||
makes it easier to generate EPUB files.
|
||||
* [crowbook-text-processing](https://github.com/lise-henry/crowbook-text-processing/)
|
||||
contains all the "typographic" functions (smart quotes, handling of non-breaking spaces in french, ...).
|
||||
contains all the "typographic" functions (smart quotes, handling of non-breaking spaces in french, ...).
|
||||
* [crowbook-intl](https://github.com/lise-henry/crowbook-intl/)
|
||||
is used for the internationalization (translation) process.
|
||||
|
||||
## License
|
||||
## License
|
||||
|
||||
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 later version.
|
||||
See
|
||||
See
|
||||
[LICENSE](LICENSE.md)
|
||||
for more information.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Roadmap
|
||||
Roadmap
|
||||
=======
|
||||
|
||||
List of features needed for 1.0 release:
|
||||
|
|
4
build.rs
4
build.rs
|
@ -13,7 +13,7 @@ fn main() {
|
|||
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/lib")).unwrap();
|
||||
// Uncomment to update crowbook.pot
|
||||
//extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/crowbook.pot")).unwrap();
|
||||
|
||||
|
||||
let mut localizer = Localizer::new(&extractor);
|
||||
localizer.add_lang("fr", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/fr.po"))).unwrap();
|
||||
let dest_path = Path::new(&env::var("OUT_DIR").unwrap())
|
||||
|
@ -25,7 +25,7 @@ fn main() {
|
|||
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bin")).unwrap();
|
||||
// Uncomment to update crowbook.pot
|
||||
//extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/bin/crowbook.pot")).unwrap();
|
||||
|
||||
|
||||
let mut localizer = Localizer::new(&extractor);
|
||||
localizer.add_lang("fr", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/bin/fr.po"))).unwrap();
|
||||
let dest_path = Path::new(&env::var("OUT_DIR").unwrap())
|
||||
|
|
|
@ -23,7 +23,7 @@ output.html: book.html
|
|||
output.html.dir: html
|
||||
output.pdf: book.pdf
|
||||
output.odt: book.odt
|
||||
|
||||
|
||||
output.base_path: docs/book/
|
||||
output.proofread.html: book.proof.html
|
||||
output.proofread.html.dir: html_proof
|
||||
|
@ -80,6 +80,3 @@ epub.version: 3
|
|||
+ guide/contribute.md
|
||||
- ChangeLog.md
|
||||
- LICENSE.md
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn get_book_options<'a>(matches: &'a ArgMatches) -> Vec<(&'a str, &'a str)>
|
|||
|
||||
/// Sets the book options according to command line arguments
|
||||
/// Also print these options to a string, so it can be used at
|
||||
/// the creation of a book to check that parameters are OK and
|
||||
/// the creation of a book to check that parameters are OK and
|
||||
/// then print them to file
|
||||
pub fn set_book_options(book: &mut Book, matches: &ArgMatches) -> String {
|
||||
let mut output = String::new();
|
||||
|
|
|
@ -38,7 +38,7 @@ fn render_format(book: &mut Book, emoji: bool, matches: &ArgMatches, format: &st
|
|||
|
||||
let mut stdout = false;
|
||||
let mut file = None;
|
||||
|
||||
|
||||
if let Some(f) = matches.value_of("output") {
|
||||
if f == "-" {
|
||||
stdout = true;
|
||||
|
@ -57,7 +57,7 @@ fn render_format(book: &mut Book, emoji: bool, matches: &ArgMatches, format: &st
|
|||
(None, _, true)
|
||||
=> book.render_format_to(format, &mut io::stdout()),
|
||||
};
|
||||
|
||||
|
||||
match result {
|
||||
Err(err) => print_error(&format!("{}", err), emoji),
|
||||
Ok(_) => {}
|
||||
|
@ -100,7 +100,7 @@ pub fn try_main() -> Result<()> {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
if matches.is_present("no-fancy") || matches.is_present("stats") {
|
||||
if matches.is_present("no-fancy") || matches.is_present("stats") {
|
||||
fancy_ui = false;
|
||||
emoji = false;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ pub fn try_main() -> Result<()> {
|
|||
book.add_progress_bar(emoji);
|
||||
}
|
||||
book.set_options(&get_book_options(&matches));
|
||||
|
||||
|
||||
{
|
||||
let res = if matches.is_present("single") {
|
||||
if s != "-" {
|
||||
|
@ -215,7 +215,7 @@ pub fn try_main() -> Result<()> {
|
|||
} else {
|
||||
book.read_config(io::stdin())
|
||||
}.map(|_| ());
|
||||
|
||||
|
||||
match res {
|
||||
Ok(..) => {},
|
||||
Err(err) => {
|
||||
|
@ -226,13 +226,13 @@ pub fn try_main() -> Result<()> {
|
|||
}
|
||||
|
||||
set_book_options(&mut book, &matches);
|
||||
|
||||
|
||||
if matches.is_present("stats") {
|
||||
let stats = Stats::new(&book, matches.is_present("verbose"));
|
||||
println!("{}", stats);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if let Some(format) = matches.value_of("to") {
|
||||
render_format(&mut book, emoji,& matches, format);
|
||||
} else {
|
||||
|
@ -272,7 +272,7 @@ pub fn try_main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ impl fmt::Display for HeaderData {
|
|||
///
|
||||
/// ```
|
||||
/// use crowbook::{Book, Number};
|
||||
/// // Create a book with some options
|
||||
/// // Create a book with some options
|
||||
/// let mut book = Book::new();
|
||||
/// book.set_options(&[("author", "Joan Doe"),
|
||||
/// ("title", "An untitled book"),
|
||||
|
@ -228,7 +228,7 @@ impl Book {
|
|||
self.bar_finish(Crowbar::Main, CrowbarState::Error, msg)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Adds a progress bar where where info should be written.
|
||||
///
|
||||
|
@ -266,7 +266,7 @@ impl Book {
|
|||
self.formats.insert(format, (description.into(), renderer));
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
/// Sets the options of a `Book`
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -344,7 +344,7 @@ impl Book {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Loads a single markdown file
|
||||
///
|
||||
/// This is *not* used to add a chapter to an existing book, but to to load the
|
||||
|
@ -448,7 +448,7 @@ impl Book {
|
|||
}
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
|
||||
/// Reads a book configuration from a `Read`able source.
|
||||
///
|
||||
/// # Book configuration
|
||||
|
@ -474,7 +474,7 @@ impl Book {
|
|||
///
|
||||
/// ! intro.md
|
||||
/// + chapter_01.md";
|
||||
///
|
||||
///
|
||||
/// let mut book = Book::new();
|
||||
/// book.read_config(content.as_bytes()); // no unwraping as `intro.md` and `chapter_01.md` don't exist
|
||||
/// ```
|
||||
|
@ -498,7 +498,7 @@ impl Book {
|
|||
.map_err(|err| Error::config_parser(Source::empty(),
|
||||
lformat!("could not read source: {error}",
|
||||
error = err)))?;
|
||||
|
||||
|
||||
// Parse the YAML block, that is, until first chapter
|
||||
let mut yaml = String::new();
|
||||
let mut lines = s.lines().peekable();
|
||||
|
@ -675,7 +675,7 @@ impl Book {
|
|||
}
|
||||
|
||||
self.bar_finish(Crowbar::Second, CrowbarState::Success, "");
|
||||
|
||||
|
||||
self.source.unset_line();
|
||||
self.set_chapter_template()?;
|
||||
Ok(self)
|
||||
|
@ -923,7 +923,7 @@ impl Book {
|
|||
/// * `render_format_to`, which writes in any `Write`able object.
|
||||
/// * `render_format`, which won't do anything if `output.{format}` isn't specified
|
||||
/// in the book configuration file.
|
||||
|
||||
|
||||
pub fn render_format_to_file<P:Into<PathBuf>>(&mut self,
|
||||
format: &str,
|
||||
path: P) -> Result<()> {
|
||||
|
@ -938,8 +938,8 @@ impl Book {
|
|||
self.bar_finish(Crowbar::Main, CrowbarState::Success, &lformat!("Finished"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Adds a chapter to the book.
|
||||
///
|
||||
|
@ -982,7 +982,7 @@ impl Book {
|
|||
file = misc::normalize(file)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// For offset: if nothing is specified, it is the filename's directory
|
||||
// If base_path.{images/links} is specified, override it for one of them.
|
||||
// If base_path is specified, override it for both.
|
||||
|
@ -1009,7 +1009,7 @@ impl Book {
|
|||
if let Ok(x) = self.options.get_bool("crowbook.files_mean_chapters") {
|
||||
add_title_if_empty = x;
|
||||
}
|
||||
|
||||
|
||||
// Add a title if there is none in the chapter (unless this is subchapter)
|
||||
if add_title_if_empty {
|
||||
misc::insert_title(&mut tokens);
|
||||
|
@ -1091,10 +1091,10 @@ impl Book {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Adds a chapter, as a file name, to the book
|
||||
///
|
||||
|
@ -1123,7 +1123,7 @@ impl Book {
|
|||
lformat!("book chapter"),
|
||||
format!("{}", path.display()))
|
||||
})?;
|
||||
|
||||
|
||||
self.add_chapter_from_named_source(number, file, f, add_title_if_empty)
|
||||
}
|
||||
|
||||
|
@ -1271,7 +1271,7 @@ impl Book {
|
|||
Header::Part => &self.part_template,
|
||||
Header::Chapter => &self.chapter_template,
|
||||
};
|
||||
|
||||
|
||||
if let Some(ref template) = *opt_template {
|
||||
template.render_data(&mut res, &data)?;
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,7 @@ pub struct Bars {
|
|||
pub mainbar: Option<ProgressBar>,
|
||||
/// Secondary bar
|
||||
pub secondbar: Option<ProgressBar>,
|
||||
/// Guard for thread
|
||||
/// Guard for thread
|
||||
pub guard: Option<thread::JoinHandle<()>>,
|
||||
/// Spinners for each renderier
|
||||
pub spinners: Vec<ProgressBar>,
|
||||
|
@ -123,7 +123,7 @@ impl Book {
|
|||
if let Some(ref mainbar) = self.bars.mainbar {
|
||||
mainbar.set_message(&lformat!("Rendering..."));
|
||||
}
|
||||
|
||||
|
||||
let bar = multibar.add(ProgressBar::new_spinner());
|
||||
bar.enable_steady_tick(200);
|
||||
bar.set_message(&lformat!("waiting..."));
|
||||
|
@ -153,14 +153,14 @@ impl Book {
|
|||
Crowbar::Main => if let Some(ref bar) = self.bars.mainbar { bar } else { return; },
|
||||
Crowbar::Second => if let Some(ref bar) = self.bars.secondbar { bar } else { return; },
|
||||
Crowbar::Spinner(i) => if i < self.bars.spinners.len() { &self.bars.spinners[i] } else { return; },
|
||||
|
||||
|
||||
};
|
||||
let emoji = self.bars.emoji;
|
||||
let mut style = match bar {
|
||||
Crowbar::Second => ProgressStyle::default_bar(),
|
||||
_ => ProgressStyle::default_spinner()
|
||||
};
|
||||
|
||||
|
||||
let color = match state {
|
||||
CrowbarState::Running => "yellow",
|
||||
CrowbarState::Success => "cyan",
|
||||
|
|
|
@ -30,7 +30,7 @@ pub trait BookRenderer: Sync {
|
|||
Err(Error::default(Source::empty(),
|
||||
lformat!("This renderer does not support the auto output")))
|
||||
}
|
||||
|
||||
|
||||
/// Render the book and write the result to the specified writer
|
||||
fn render(&self, book: &Book, to: &mut dyn Write) -> Result<()>;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ lang:meta:en # {lang}
|
|||
subject:meta # {subject}
|
||||
description:meta # {description}
|
||||
cover:path # {cover}
|
||||
|
||||
|
||||
# {metadata2}
|
||||
subtitle:meta # {subtitle}
|
||||
license:meta # {license}
|
||||
|
@ -224,7 +224,7 @@ crowbook.verbose:alias # {removed}
|
|||
prf_opt = lformat!("Output options (for proofreading)"),
|
||||
prf_opt2 = lformat!("Proofreading options (only for output.proofread.* targets)"),
|
||||
deprecated_opt = lformat!("Deprecated options"),
|
||||
|
||||
|
||||
author = lformat!("Author of the book"),
|
||||
title = lformat!("Title of the book"),
|
||||
lang = lformat!("Language of the book"),
|
||||
|
@ -237,7 +237,7 @@ crowbook.verbose:alias # {removed}
|
|||
version = lformat!("Version of the book"),
|
||||
date = lformat!("Date the book was revised"),
|
||||
autograph = lformat!("An autograph"),
|
||||
|
||||
|
||||
output_epub = lformat!("Output file name for EPUB rendering"),
|
||||
output_html = lformat!("Output file name for HTML rendering"),
|
||||
output_tex = lformat!("Output file name for LaTeX rendering"),
|
||||
|
@ -260,7 +260,7 @@ crowbook.verbose:alias # {removed}
|
|||
roman_numerals_parts = lformat!("If set to true, display part number with roman numerals"),
|
||||
roman_numerals_chapters = lformat!("If set to true, display chapter number with roman numerals"),
|
||||
reset_counter = lformat!("If set to true, reset chapter number at each part"),
|
||||
|
||||
|
||||
import_config = lformat!("Import another book configuration file"),
|
||||
|
||||
html_icon = lformat!("Path to an icon to be used for the HTML files(s)"),
|
||||
|
@ -275,7 +275,7 @@ crowbook.verbose:alias # {removed}
|
|||
highlight_css = lformat!("Set another highlight.js CSS theme than the default one"),
|
||||
side_notes = lformat!("Display footnotes as side notes in HTML/Epub (experimental)"),
|
||||
nb_spaces = lformat!("Replace unicode non breaking spaces with HTML entities and CSS"),
|
||||
|
||||
|
||||
one_chapter = lformat!("Display only one chapter at a time (with a button to display all)"),
|
||||
single_html = lformat!("Path of an HTML template for standalone HTML"),
|
||||
single_js = lformat!("Path of a javascript file"),
|
||||
|
@ -287,13 +287,13 @@ crowbook.verbose:alias # {removed}
|
|||
html_chapter_template = lformat!("Inline template for HTML chapter formatting"),
|
||||
html_part_template = lformat!("Inline template for HTML part formatting"),
|
||||
html_dir_template = lformat!("Path of a HTML template for multifile HTML"),
|
||||
|
||||
|
||||
epub_ver = lformat!("EPUB version to generate (2 or 3)"),
|
||||
epub_css = lformat!("Path of a stylesheet for EPUB"),
|
||||
epub_css_add = lformat!("Inline CSS added to the EPUB stylesheet template"),
|
||||
chapter_xhtml = lformat!("Path of an xhtml template for each chapter"),
|
||||
epub_toc = lformat!("Add 'Title' and (if set) 'Cover' in the EPUB table of contents"),
|
||||
|
||||
|
||||
tex_links = lformat!("Add foontotes to URL of links so they are readable when printed"),
|
||||
tex_command = lformat!("LaTeX command to use for generating PDF"),
|
||||
tex_tmpl = lformat!("Path of a LaTeX template file"),
|
||||
|
@ -308,7 +308,7 @@ crowbook.verbose:alias # {removed}
|
|||
tex_font_size = lformat!("Specify latex font size (in pt, 10 (default), 11, or 12 are accepted)"),
|
||||
tex_hyperref = lformat!("If disabled, don't try to find references inside the document"),
|
||||
tex_stdpage = lformat!("If set to true, use 'stdpage' package to format a manuscript according to standards"),
|
||||
|
||||
|
||||
rs_files = lformat!("Whitespace-separated list of files to embed in e.g. EPUB file; useful for including e.g. fonts"),
|
||||
rs_out = lformat!("Paths where additional resources should be copied in the EPUB file or HTML directory"),
|
||||
rs_base = lformat!("Path where to find resources (in the source tree). By default, links and images are relative to the Markdown file. If this is set, it will be to this path."),
|
||||
|
@ -316,7 +316,7 @@ crowbook.verbose:alias # {removed}
|
|||
rs_img = lformat!("Set base path but only for images. Useless if resources.base_path is set"),
|
||||
rs_base_files = lformat!("Set base path but only for additional files. Useless if resources.base_path is set."),
|
||||
rs_tmpl = lformat!("Set base path but only for templates files. Useless if resources.base_path is set"),
|
||||
|
||||
|
||||
autoclean = lformat!("Toggle typographic cleaning of input markdown according to lang"),
|
||||
smart_quotes = lformat!("If enabled, tries to replace vertical quotations marks to curly ones"),
|
||||
ligature_dashes = lformat!("If enabled, replaces '--' to en dash ('–') and '---' to em dash ('—')"),
|
||||
|
@ -327,7 +327,7 @@ crowbook.verbose:alias # {removed}
|
|||
files_mean_chapters = lformat!("Consider that a new file is always a new chapter, even if it does not include heading (default: only for numbered chapters)"),
|
||||
tmp_dir = lformat!("Path where to create a temporary directory (default: uses result from Rust's std::env::temp_dir())"),
|
||||
zip = lformat!("Command to use to zip files (for EPUB/ODT)"),
|
||||
|
||||
|
||||
prf_html = lformat!("Output file name for HTML rendering with proofread features"),
|
||||
prf_html_dir = lformat!("Output directory name for HTML rendering with proofread features"),
|
||||
prf_pdf = lformat!("Output file name for PDF rendering with proofread features"),
|
||||
|
@ -346,7 +346,7 @@ crowbook.verbose:alias # {removed}
|
|||
tex_theme = lformat!("If set, set theme for syntax highlighting for LaTeX/PDF output (syntect only)"),
|
||||
html_theme = lformat!("If set, set theme for syntax highlighting for HTML output (syntect only)"),
|
||||
epub_theme = lformat!("If set, set theme for syntax highlighting for EPUB output (syntect only)"),
|
||||
|
||||
|
||||
renamed = lformat!("Renamed"),
|
||||
removed = lformat!("Removed"),
|
||||
);
|
||||
|
@ -549,7 +549,7 @@ impl BookOptions {
|
|||
let options = mem::replace(&mut book.options, BookOptions::new());
|
||||
self.merge(options)?;
|
||||
Ok(None)
|
||||
} else {
|
||||
} else {
|
||||
Ok(self.options.insert(key, BookOption::Path(value)))
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -64,7 +64,7 @@ impl Default {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Cleaner for Default {
|
||||
/// Remove unnecessary whitespaces
|
||||
fn clean<'a>(&self, input: Cow<'a, str>, _: bool) -> Cow<'a, str> {
|
||||
|
|
|
@ -85,7 +85,7 @@ impl<'a> EpubRenderer<'a> {
|
|||
if self.html.book.options.get_i32("epub.version").unwrap() == 3 {
|
||||
maker.epub_version(EpubVersion::V30);
|
||||
}
|
||||
|
||||
|
||||
let lang = self.html.book.options.get_str("lang").unwrap();
|
||||
let toc_extras = self.html.book.options.get_bool("epub.toc.extras").unwrap();
|
||||
maker.metadata("lang", lang)?;
|
||||
|
@ -103,7 +103,7 @@ impl<'a> EpubRenderer<'a> {
|
|||
if let Ok(license) = self.html.book.options.get_str("license") {
|
||||
maker.metadata("license", license)?;
|
||||
}
|
||||
|
||||
|
||||
// if self.html.book.options.get_bool("epub.toc.extras").unwrap() == true {
|
||||
// if self.html.book.options.get("cover").is_ok() {
|
||||
// self.html.toc.add(1,
|
||||
|
@ -115,8 +115,8 @@ impl<'a> EpubRenderer<'a> {
|
|||
// lang::get_str(lang, "title"));
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// /* If toc will be rendered inline, add it... to the toc (yeah it's meta) */
|
||||
// if self.html.book.options.get_bool("rendering.inline_toc").unwrap() == true {
|
||||
// self.html.toc.add(1,
|
||||
|
@ -125,7 +125,7 @@ impl<'a> EpubRenderer<'a> {
|
|||
// "toc"));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
for (i, chapter) in self.html.book.chapters.iter().enumerate() {
|
||||
self.html.handler.add_link(chapter.filename.as_str(), filenamer(i));
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ impl<'a> EpubRenderer<'a> {
|
|||
maker.inline_toc();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write chapters
|
||||
let template_chapter =
|
||||
compile_str(self.html.book.get_template("epub.chapter.xhtml")?.as_ref(),
|
||||
|
@ -246,7 +246,7 @@ impl<'a> EpubRenderer<'a> {
|
|||
}
|
||||
|
||||
maker.generate(to)?;
|
||||
|
||||
|
||||
Ok(String::new())
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ impl BookRenderer for Epub {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.epub", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn Write) -> Result<()> {
|
||||
EpubRenderer::new(book)?
|
||||
.render_book(to)?;
|
||||
|
|
|
@ -55,7 +55,7 @@ struct GrammalecteData {
|
|||
struct GrammalecteCheck {
|
||||
data: Vec<GrammalecteData>,
|
||||
}
|
||||
|
||||
|
||||
/// Grammalecte Checker
|
||||
pub struct GrammalecteChecker {
|
||||
port: usize,
|
||||
|
@ -155,7 +155,7 @@ impl GrammalecteChecker {
|
|||
}
|
||||
Ok(())
|
||||
},
|
||||
|
||||
|
||||
_ => Ok(()),
|
||||
}
|
||||
})
|
||||
|
|
|
@ -142,7 +142,7 @@ impl GrammarChecker {
|
|||
}
|
||||
Ok(())
|
||||
},
|
||||
|
||||
|
||||
_ => Ok(()),
|
||||
}
|
||||
})
|
||||
|
|
|
@ -178,7 +178,7 @@ impl<'a> HtmlDirRenderer<'a> {
|
|||
// Render each chapter and write them, and index.html too
|
||||
fn write_html(&mut self) -> Result<()> {
|
||||
let mut chapters = vec![];
|
||||
|
||||
|
||||
let mut titles = vec![];
|
||||
let mut titles_raw = vec![];
|
||||
for (i, chapter) in self.html.book.chapters.iter().enumerate() {
|
||||
|
@ -310,7 +310,7 @@ impl<'a> HtmlDirRenderer<'a> {
|
|||
let mut f = |key| {
|
||||
self.render_vec(&Parser::new().parse_inline(self.html.book.options.get_str(key)?)?)
|
||||
};
|
||||
|
||||
|
||||
format!("<h2 class = 'author'>{author}</h2>
|
||||
<h1 class = 'title'>{title}</h1>
|
||||
<h2 class = 'subtitle'>{subtitle}</h2>
|
||||
|
@ -456,12 +456,12 @@ impl BookRenderer for HtmlDir {
|
|||
fn auto_path(&self, _: &str) -> Result<String> {
|
||||
Ok(String::from("output_html"))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, _: &Book, _: &mut dyn io::Write) -> Result<()> {
|
||||
Err(Error::render(Source::empty(),
|
||||
lformat!("can only render HTML directory to a path, not to a stream")))
|
||||
}
|
||||
|
||||
|
||||
fn render_to_file(&self, book: &Book, path: &Path) -> Result<()> {
|
||||
HtmlDirRenderer::new(book)?
|
||||
.render_book(path)?;
|
||||
|
@ -473,12 +473,12 @@ impl BookRenderer for ProofHtmlDir {
|
|||
fn auto_path(&self, _: &str) -> Result<String> {
|
||||
Ok(String::from("output_html_proof"))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, _: &Book, _: &mut dyn io::Write) -> Result<()> {
|
||||
Err(Error::render(Source::empty(),
|
||||
lformat!("can only render HTML directory to a path, not to a stream")))
|
||||
}
|
||||
|
||||
|
||||
fn render_to_file(&self, book: &Book, path: &Path) -> Result<()> {
|
||||
HtmlDirRenderer::new(book)?
|
||||
.proofread()
|
||||
|
|
|
@ -65,14 +65,14 @@ impl<'a> HtmlIfRenderer<'a> {
|
|||
let mut contains_md = false;
|
||||
let mut i = 0;
|
||||
let mut variables = vec![];
|
||||
|
||||
|
||||
while let Some(begin) = code[i..].find("@\"") {
|
||||
let begin = i + begin;
|
||||
if let Some(len) = code[begin..].find("\"@") {
|
||||
contains_md = true;
|
||||
let end = begin + len;
|
||||
gen_code.push_str(&code[i..begin]);
|
||||
|
||||
|
||||
let mut md_part = &code[begin+2..end];
|
||||
let rendered = self.render_vec(&Parser::new().parse(md_part)?)?;
|
||||
while let Some(b) = md_part.find("{{") {
|
||||
|
@ -82,7 +82,7 @@ impl<'a> HtmlIfRenderer<'a> {
|
|||
}
|
||||
}
|
||||
gen_code.push_str("crowbook_return_variable += \"");
|
||||
gen_code.push_str(&rendered
|
||||
gen_code.push_str(&rendered
|
||||
.replace('"', "\\\"")
|
||||
.replace('\n', "\\\n"));
|
||||
gen_code.push('"');
|
||||
|
@ -145,7 +145,7 @@ return crowbook_return_variable.replace(/<\\/ul><ul>/g, '');\n",
|
|||
let html_if: &mut HtmlIfRenderer = this.as_mut();
|
||||
let content = html_if.parse_inner_code(code)?;
|
||||
Ok(content)
|
||||
|
||||
|
||||
},
|
||||
Token::CodeBlock(ref language, ref code) if language.starts_with(|c| c == '<' || c == '>') => {
|
||||
let html_if: &mut HtmlIfRenderer = this.as_mut();
|
||||
|
@ -229,7 +229,7 @@ return crowbook_return_variable.replace(/<\\/ul><ul>/g, '');\n",
|
|||
if !post_code.is_empty() {
|
||||
chapter_content.push_str(&self.parse_inner_code(post_code)?);
|
||||
}
|
||||
|
||||
|
||||
chapters.push(format!("<div id = \"chapter-{}\" class = \"chapter\">
|
||||
{}
|
||||
</div>",
|
||||
|
@ -242,7 +242,7 @@ return crowbook_return_variable.replace(/<\\/ul><ul>/g, '');\n",
|
|||
code = self.curr_init));
|
||||
self.curr_init = String::new();
|
||||
}
|
||||
|
||||
|
||||
self.html.source = Source::empty();
|
||||
|
||||
for chapter in &chapters {
|
||||
|
@ -333,7 +333,7 @@ impl BookRenderer for HtmlIf {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.html", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
let mut html = HtmlIfRenderer::new(book)?;
|
||||
let result = html.render_book()?;
|
||||
|
|
|
@ -92,7 +92,7 @@ impl<'a> HtmlSingleRenderer<'a> {
|
|||
self.html.handler.add_link(chapter.filename.as_str(),
|
||||
format!("#chapter-{}", i));
|
||||
}
|
||||
|
||||
|
||||
for (i, chapter) in self.html.book.chapters.iter().enumerate() {
|
||||
let n = chapter.number;
|
||||
let v = &chapter.content;
|
||||
|
@ -271,7 +271,7 @@ impl BookRenderer for HtmlSingle {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.html", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
let mut html = HtmlSingleRenderer::new(book)?;
|
||||
let result = html.render_book()?;
|
||||
|
@ -288,7 +288,7 @@ impl BookRenderer for ProofHtmlSingle {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.proof.html", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
let mut html = HtmlSingleRenderer::new(book)?
|
||||
.proofread();
|
||||
|
|
|
@ -139,7 +139,7 @@ impl<'a> LatexRenderer<'a> {
|
|||
for (i, chapter) in self.book.chapters.iter().enumerate() {
|
||||
self.handler.add_link(chapter.filename.as_str(), format!("chapter-{}", i));
|
||||
}
|
||||
|
||||
|
||||
for (i, chapter) in self.book.chapters.iter().enumerate() {
|
||||
let n = chapter.number;
|
||||
self.current_chapter = n;
|
||||
|
@ -560,7 +560,7 @@ impl BookRenderer for Latex {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.tex", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
let mut latex = LatexRenderer::new(book);
|
||||
let result = latex.render_book()?;
|
||||
|
@ -577,7 +577,7 @@ impl BookRenderer for ProofLatex {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.proof.tex", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
let mut latex = LatexRenderer::new(book).proofread();
|
||||
let result = latex.render_book()?;
|
||||
|
@ -594,7 +594,7 @@ impl BookRenderer for Pdf {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.pdf", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
LatexRenderer::new(book)
|
||||
.render_pdf(to)?;
|
||||
|
@ -606,7 +606,7 @@ impl BookRenderer for ProofPdf {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.proof.pdf", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut dyn io::Write) -> Result<()> {
|
||||
LatexRenderer::new(book)
|
||||
.proofread()
|
||||
|
|
|
@ -94,7 +94,7 @@ impl<'a> OdtRenderer<'a> {
|
|||
features = missing));
|
||||
}
|
||||
|
||||
|
||||
|
||||
let mut content = String::new();
|
||||
|
||||
for chapter in &self.book.chapters {
|
||||
|
@ -115,7 +115,7 @@ impl<'a> OdtRenderer<'a> {
|
|||
self.current_numbering = 0;
|
||||
self.current_hide = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if n.is_part() {
|
||||
error!("{}", lformat!("Parts are not supported yet in ODT"));
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ impl<'a> OdtRenderer<'a> {
|
|||
s)
|
||||
}
|
||||
Token::Emphasis(ref vec) => {
|
||||
format!("<text:span text:style-name=\"T1\">{}</text:span>",
|
||||
format!("<text:span text:style-name=\"T1\">{}</text:span>",
|
||||
self.render_vec(vec))
|
||||
}
|
||||
Token::Strong(ref vec) => {
|
||||
|
@ -245,7 +245,7 @@ impl BookRenderer for Odt {
|
|||
fn auto_path(&self, book_name: &str) -> Result<String> {
|
||||
Ok(format!("{}.odt", book_name))
|
||||
}
|
||||
|
||||
|
||||
fn render(&self, book: &Book, to: &mut Write) -> Result<()> {
|
||||
OdtRenderer::new(book)
|
||||
.render_book(to)?;
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Parser {
|
|||
parser.superscript = book.options.get_bool("crowbook.markdown.superscript").unwrap();
|
||||
parser
|
||||
}
|
||||
|
||||
|
||||
/// Enable/disable HTML as text
|
||||
pub fn html_as_text(&mut self, b: bool) {
|
||||
self.html_as_text = b;
|
||||
|
@ -189,7 +189,7 @@ impl Parser {
|
|||
self.parse_super_vec(&mut res);
|
||||
self.parse_sub_vec(&mut res);
|
||||
}
|
||||
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ impl Parser {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Looks for super script in a vector of tokens
|
||||
fn parse_super_vec(&mut self, v: &mut Vec<Token>) {
|
||||
for i in 0..v.len() {
|
||||
|
@ -273,7 +273,7 @@ impl Parser {
|
|||
} else {
|
||||
if v[i].is_code() || !v[i].is_container() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(ref mut inner) = v[i].inner_mut() {
|
||||
self.parse_super_vec(inner);
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ impl Parser {
|
|||
} else {
|
||||
if v[i].is_code() || !v[i].is_container() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(ref mut inner) = v[i].inner_mut() {
|
||||
self.parse_sub_vec(inner);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ impl Parser {
|
|||
} else {
|
||||
debug!("{}", lformat!("ignoring HTML block '{}'", text));
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Event::Text(text) => {
|
||||
v.push(Token::Str(text.into_owned()));
|
||||
|
|
|
@ -74,7 +74,7 @@ impl RepetitionDetector {
|
|||
.map_err(|err| Error::default(Source::empty(),
|
||||
lformat!("error detecting repetitions: {err}",
|
||||
err = err)))?;
|
||||
|
||||
|
||||
parser.detect_local(&mut ast, self.threshold);
|
||||
let repetitions = parser.ast_to_repetitions(&ast);
|
||||
for repetition in &repetitions {
|
||||
|
@ -91,4 +91,4 @@ impl RepetitionDetector {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ impl ResourceHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn is_local(path: &str) -> bool {
|
||||
!path.contains("://") // todo: use better algorithm
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ impl Syntax {
|
|||
theme: theme,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Convert a string containing code to HTML
|
||||
pub fn to_html(&self, code: &str, language: &str) -> Result<String> {
|
||||
let language = strip_language(language);
|
||||
|
@ -78,7 +78,7 @@ impl Syntax {
|
|||
.unwrap_or_else(|| self.syntax_set.find_syntax_plain_text());
|
||||
let mut h = syntect::easy::HighlightLines::new(syntax, &self.theme);
|
||||
let regions = h.highlight(code, &self.syntax_set);
|
||||
|
||||
|
||||
let mut result = String::with_capacity(code.len());
|
||||
for (style, text) in regions {
|
||||
let mut content = escape::tex(text).into_owned();
|
||||
|
|
|
@ -30,14 +30,14 @@ pub fn traverse_token<F1, F2, R>(token: &Token, f: &F1, add: &F2) -> R
|
|||
Token::Str(ref s) | Token::Code(ref s) | Token::CodeBlock(_, ref s) => f(s),
|
||||
|
||||
Token::SoftBreak => f(" "),
|
||||
|
||||
|
||||
Token::Rule |
|
||||
Token::HardBreak => f("\n"),
|
||||
|
||||
Token::Image(..) |
|
||||
Token::StandaloneImage(..) |
|
||||
Token::FootnoteDefinition(..) |
|
||||
Token::FootnoteReference(..) |
|
||||
Token::FootnoteReference(..) |
|
||||
Token::Table(..) |
|
||||
Token::TableHead(..) |
|
||||
Token::TableRow(..) |
|
||||
|
|
Loading…
Reference in New Issue