1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-09-22 13:21:37 +02:00
Commit Graph

263 Commits

Author SHA1 Message Date
Elisabeth Henry
86d5b3886f Modify book::render_format method 2016-12-20 15:50:10 +01:00
Elisabeth Henry
a8d5f52d41 Make html_dir implement the BookRenderer trait 2016-12-20 15:42:55 +01:00
Elisabeth Henry
a857eeb170 Make all but html_dir use BookRenderer trait 2016-12-20 15:31:08 +01:00
Elisabeth Henry
abe65ab8f3 Implement BookRenderer for LatexRenderer 2016-12-20 13:29:13 +01:00
Elisabeth Henry
b61bdf1c94 Implement BookRenderer for HTMLSingleRenderer 2016-12-20 13:16:24 +01:00
Elisabeth Henry
f41331010a Add BookRenderer trait 2016-12-20 12:36:07 +01:00
Elisabeth Henry
2473bf5a70 Refactor Book api 2016-12-20 11:38:39 +01:00
Elisabeth Henry
1467f8ba89 Refactor API 2016-12-20 11:26:34 +01:00
Elisabeth Henry
7f3f74e537 Make chapters, filenames and options from Book public 2016-12-20 10:40:45 +01:00
Elisabeth Henry
156a2bfc5e Rename canonicalize as normalize 2016-12-16 01:34:37 +01:00
Elisabeth Henry
309e523f3b Use canonicalize to display generated (or other) file names
Should fix #30
2016-12-16 00:38:54 +01:00
Elisabeth Henry
c8cf3ab9ec Fix warning resulting from mustache 0.8 update 2016-11-18 16:48:37 +01:00
Elisabeth Henry
8c8b7029dc Update mustache to 0.8 2016-11-18 16:39:28 +01:00
Elisabeth Henry
4c5f7b0f4f Use '?' operator in book.rs 2016-11-10 21:30:37 +01:00
Elisabeth Henry
46a5685d65 Fix escaping of author and title 2016-10-27 16:24:34 +02:00
Elisabeth Henry
b44ae86cd2 Implement input.clean.ligature.guillemets and input.clean.ligature.dashes
This should fix #17
2016-10-21 14:52:57 +02:00
Elisabeth Henry
073e8b0f07 Clean cleaning options
* `input.autoclean` has been renamed `input.clean`.
 * `input.smart_quotes` has been renamed `input.clean.smart_quotes`.
 * added `input.clean.ligature.dashes` and `input.clean.ligature.guillemets`.
2016-10-21 14:15:17 +02:00
Elisabeth Henry
2d793c5471 Use lformat! for an untranslated string 2016-10-18 05:51:12 +02:00
Elisabeth Henry
2818a699f7 Add input.smart_quotes option 2016-10-18 00:33:42 +02:00
Elisabeth Henry
006cb0468f Use lformat! for a previously forgotten string 2016-10-13 23:17:28 +02:00
Elisabeth Henry
9389e34a89 Run rustfmt 2016-10-13 04:06:15 +02:00
Elisabeth Henry
39b7259908 Fix string formatting problems 2016-10-12 23:39:44 +02:00
Elisabeth Henry
90cefa7e8c Add named arguments to lformat! 2016-10-12 23:19:23 +02:00
Elisabeth Henry
0cfe5ba502 Add more calls to lformat! 2016-10-12 20:57:37 +02:00
Elisabeth Henry
82e56dc287 Add more calls to lformat! 2016-10-12 20:55:08 +02:00
Elisabeth Henry
80c6431648 Use FrenchFormatter.format_tex in French cleaner 2016-10-12 01:41:57 +02:00
Elisabeth Henry
5c41059719 Add lformat! calls for book.rs and odt.rs 2016-10-09 20:12:17 +02:00
Elisabeth Henry
3d79b5dd05 Use crowbook-localize 0.0.4 2016-10-09 02:45:19 +02:00
Elisabeth Henry
934591b019 More strings translated in french 2016-10-07 23:10:35 +02:00
Elisabeth Henry
ca5ce3f9e6 More strings translated in french 2016-10-07 23:01:16 +02:00
Elisabeth Henry
aa6cf82b66 Started french localization 2016-10-07 20:47:21 +02:00
Elisabeth Henry
8ea645b874 Add html.css.colours template
This is done so it is possible to only override the colour scheme, while
not having to generate a whole new CSS file.

Also, instead of e.g. {{fr}} being set to true if lang is "fr",
it's now {{lang_fr}}.
2016-10-06 19:36:34 +02:00
Elisabeth Henry
b9ea1a1b68 Run grammar checker even if --single is set 2016-09-29 02:12:10 +02:00
Elisabeth Henry
cbb0a782ab Add proofread option to disable proofreading outputs when running crowbook 2016-09-29 01:01:48 +02:00
Elisabeth Henry
f3375d5ca7 Add --to options for proofread books 2016-09-28 23:55:23 +02:00
Elisabeth Henry
4f8f1e3f31 Update guide to 0.9.x 2016-09-28 21:25:26 +02:00
Elisabeth Henry
a4e33d2062 Parallelize (again...) grammar checking 2016-09-28 04:21:55 +02:00
Elisabeth Henry
ad1a8430d6 Handle error more nicely (ie. gracefully continue) if languagetool server is not running 2016-09-28 01:37:18 +02:00
Elisabeth Henry
28ab9e5c1f Add proofread.languagetool and proofread.languagetool.port options 2016-09-28 01:28:32 +02:00
Elisabeth Henry
913934d038 Run grammar checking on 4 threads 2016-09-27 19:30:06 +02:00
Elisabeth Henry
5ecf4ed774 Make 'not generating proofread because not compiled with proofread feature' display as a warning 2016-09-27 17:42:08 +02:00
Elisabeth Henry
af4f5e4764 Add output.proofread.pdf output 2016-09-27 16:51:12 +02:00
Elisabeth Henry
ff8d42349a Make hyper and url optional dependencies
Also, rename "repetitions" feature into a more general "proofread"
2016-09-27 05:54:11 +02:00
Elisabeth Henry
5a6bcc9680 Add url dependency to encode query 2016-09-27 05:32:00 +02:00
Elisabeth Henry
af39a6255b Refactorize 'a bit' 2016-09-27 03:15:40 +02:00
Elisabeth Henry
ac283daeaa Merge support for LanguageTool 2016-09-26 20:49:27 +02:00
Elisabeth Henry
04081b5514 Rewrite render_all 2016-09-26 04:29:37 +02:00
Elisabeth Henry
16488b718c Add output.proofread.html and output.proofread.html_dir options 2016-09-26 02:41:48 +02:00
Elisabeth Henry
8e3beec5c5 Move render_pdf at the beginning of the render_all, since it takes the most time 2016-09-25 02:46:46 +02:00
Elisabeth Henry
ac91be8f48 Cache template for chapter header 2016-09-24 06:38:38 +02:00
Elisabeth Henry
e1a4dbe415 Fix epubcheck for 2.0 2016-09-22 23:16:02 +02:00
Elisabeth Henry
6c5c716755 Renamed book.get_header to book_get_chapter_header 2016-09-22 15:03:55 +02:00
Elisabeth Henry
bf6d3d189f Make the templates.rs and templates/ structure match templates names
Also:
* html_dir.css has been suppressed, it can point to html.css
* html_single.js can contain html.js even if it is not the default template
2016-09-22 05:42:02 +02:00
Elisabeth Henry
7371fbeb5a Rename html.print_css to html.css.print 2016-09-22 05:08:29 +02:00
Elisabeth Henry
308c2215dc Renamed html.script to html_single.js 2016-09-22 04:53:20 +02:00
Elisabeth Henry
c5f7090f17 Replace tex.short option by a tex.class
Default is book.

Additionally, if class isn't book, set `open_any` flag in template so margins
can be symmetrical except for `book` class.
2016-09-22 03:39:27 +02:00
Elisabeth Henry
38d3da6e6e Rename numbering options
numbering => rendering.num_depth
numbering_template => rendering.chapter_template
2016-09-22 02:32:40 +02:00
Elisabeth Henry
f9ea2e4d38 Rename options
enable_yaml_blocks -> input.yaml_blocks
use_initials -> input.initials
autoclean -> input.autoclean
2016-09-22 02:07:38 +02:00
Elisabeth Henry
aaf5b1083a Add a lot of #[doc(hidden)] to reduce API's surface 2016-09-21 13:24:47 +02:00
Elisabeth Henry
592a96178c Change too much stuff at a time
* replace book.get_mapbuilder by book.get_metadata
* metadata can now contained markdown and will be rendered
* fix some templates since there is no more need for escaping
* use book::compile_str instead of mustache::compile_str to avoid panics
2016-09-21 13:01:03 +02:00
Elisabeth Henry
98b6a88e57 Avoid panicking when mustache can't compile a template
Uses std:🧵:spawn to transform a panic into an Error.

Fixes #20
2016-09-21 03:18:35 +02:00
Elisabeth Henry
9db161e999 Export crowbook_version to CARGO_PKG_VERSION 2016-09-20 05:37:30 +02:00
Elisabeth Henry
0ff7678170 Fix support for custom metadata 2016-09-20 04:58:25 +02:00
Elisabeth Henry
b52cbefa90 Add support for more metadata 2016-09-20 04:19:29 +02:00
Elisabeth Henry
f0dff0028d Improve error messages 2016-09-20 03:34:33 +02:00
Elisabeth Henry
71806aefb4 Try to work on line number in book::new_from_config 2016-09-20 01:57:30 +02:00
Elisabeth Henry
8f143264fa Give suggestion when running crowbook without -s on a .md file 2016-09-20 01:54:00 +02:00
Elisabeth Henry
474992b09e Make Cleaner trait use Cow 2016-09-19 21:26:50 +02:00
Elisabeth Henry
7aaec8fdf9 Make escape functions use Cow 2016-09-19 21:10:14 +02:00
Elisabeth Henry
4b5177475c Refactor Error struct 2016-09-19 20:33:07 +02:00
Elisabeth Henry
158d765026 Try to read yaml line by line so options are set in order of declaration 2016-09-18 23:59:04 +02:00
Elisabeth Henry
96e741ac33 Remove unnecessary clone in Book::new_from_file 2016-09-18 23:04:27 +02:00
Elisabeth Henry
5798922e4c Split HtmlRenderer into one 'abstract class' and a concrete singlefile renderer 2016-09-18 03:05:03 +02:00
Elisabeth Henry
73ebf2f1dc Add html.highlight.css and html.highlight.js options 2016-09-16 21:37:35 +02:00
Elisabeth Henry
bf1be4525e Use crossbeam to parallelize rendering of different formats 2016-09-13 02:30:05 +02:00
Elisabeth Henry
f4f961d75d Make error message clearer when cover is not found 2016-09-11 14:54:27 +02:00
Elisabeth Henry
0d70dbd282 Move overriding previous set key to error instead of warning 2016-09-11 14:16:58 +02:00
Elisabeth Henry
1faf8110f6 Add description of the missing file for Error::FileNotFound 2016-09-11 14:02:38 +02:00
Elisabeth Henry
960cd19c53 Refactor Errors
The purpose of this is to add `Source` information to (hopefully,
most) errors, so crowbook can display the file where an error occurred
and, in some cases, its line number.
2016-09-11 05:26:11 +02:00
Elisabeth Henry
45664b0370 Fix(?) formatting in docstring 2016-09-11 02:46:31 +02:00
Elisabeth Henry
23396e7f6b Make unknown key in inline YAML block issue a warnig message 2016-05-08 18:25:51 +02:00
Elisabeth Henry
4eb80359e9 Fix cleaner setting when lang is set in inline YAML block 2016-05-07 05:47:03 +02:00
Elisabeth Henry
af56d6cedf Add latex option to cleaning mechanism
Cleaning is now also used when LaTeX is generated, e.g. replacing '«
Salut ! »' by '«~Salut~!~»' if lang is set to fr and autoclean is
activated.
2016-05-04 19:11:51 +02:00
Elisabeth Henry
553f44f788 Remove nb_char field from french cleaner 2016-04-15 14:37:32 +02:00
Elisabeth Henry
05e1f530ee Complete localization support 2016-04-02 14:19:36 +02:00
Elisabeth Henry
9f65a4ff89 Add CSS stylesheet for print media 2016-03-15 19:50:11 +01:00
Elisabeth Henry
1ab2377e71 Separated html.script and html_dir.script 2016-03-12 14:24:18 +01:00
Elisabeth Henry
f42ace238c Add html.script option to specify javascript file to use
Also, various templates use this value instead of hard-coding the
javascript code (and duplicating it three times).
2016-03-06 02:35:11 +01:00
Elisabeth Henry
21ec13a79a Add (not yet complete) HtmlDirRenderer
For rendering a multiple-files HTML in a directory, in `output.html_dir`.
2016-03-05 22:02:27 +01:00
Elisabeth Henry
fd31be67d7 Add templates for html_dir output 2016-03-05 20:35:11 +01:00
Elisabeth Henry
2aa1139baf Rename book options base_path* to resources.base_path*
This is to ensure a bit more consistency in the ways options are named
and grouped.

Also added a (not very satisfying) way to warn that an option that is
being used is deprecated and should be replaced with the new one.
2016-03-05 18:02:45 +01:00
Elisabeth Henry
f382c92ed9 Make code a bit more rustic applying clippy's advices 2016-03-05 14:53:41 +01:00
Elisabeth Henry
9980739ed4 Make Error::Render contain a String instead of a &'static str
Also, more errors that should theoretically not happened have been
turned to panic!s
2016-03-04 19:26:23 +01:00
Elisabeth Henry
54ca041d5a Clean Book constructors API
- Book::new takes an additional `options` parameter.
- Book::new_from_file_with_options becomes `new_from_file`, which got
  deleted.

This way, each constructor takes an `options` parameter (which can
be set to `&[]` for default options), allowing derived constructors to
not replicate the setting options code.
2016-03-03 20:56:28 +01:00
Elisabeth Henry
4b22f9a339 Add enable_yaml_mode option
This option activates or disables the parsing of YAML block. If
disabled, YAML blocks will be ignored and won't be used to try to set
Crowbook's options.

enable_yaml_mode is false by defaut, but set to true when crowbook is
called with `--single`.
2016-03-02 20:38:35 +01:00
Elisabeth Henry
1ad7a5d847 Set book options before parsing chapters
When run with --set, Crowbook now sets book options before chapters
are set. This allows to set book_path (or its variants) with --set
(previously it had no effect because it was only in place after the
chapters were parsed.)

Should fix #5.
2016-03-02 16:40:03 +01:00
Elisabeth Henry
38a0656f9f Add new option tex.short
This option makes LaTeX uses the article class instead of book, and
uses the default \maketitle command for it. This option is set to
false by default, but automatically enabled when runned with
--single.

(This commit also fixes a bug for path resolution when crowbook
is runned in single. Thiss should have been a separate commit, ooops.)

Resolves: #3
2016-03-02 03:58:42 +01:00
Elisabeth Henry
0495791072 Fix commentary indentation in book.rs 2016-03-02 02:33:40 +01:00
Elisabeth Henry
d0f006f81d Add base_path, base_path.links and base_path.images options
By default, links are computed relatively to the Markdown file that
uses them. Setting `base_path` allows to override this behaviour: in
this case, links will be relative to this path.

`base_path` sets the paths both for images and links, but it is
possible to set them independently, respectively with base_path.images
and base_path.links. Note that if base_path is set, these two options
won't be looked at.

Should fix issue #5.
2016-03-02 02:12:23 +01:00
Elisabeth Henry
6e99258062 Set book's path when creating with new_from_markdown_file
This should allow a single markdown file to link to e.g. a cover file
and still be rendered correctly even if crowbook is called from
another directory.
2016-03-01 18:28:49 +01:00
Elisabeth Henry
61f4dabff5 Add Book::new_from_markdown_file method
This method allows to create a book from a single markdown file.
2016-03-01 17:36:47 +01:00
Elisabeth Henry
9a181f9663 Parse book configuration file with yaml-rust
The first part of a `.book` file, setting book options, is now parsed
as true YAML by the yaml-rust library instead of using a custom
parser.
2016-03-01 17:23:03 +01:00
Elisabeth Henry
0a39bee213 Make Book parse inline yaml blocks, not just ignoring them. 2016-03-01 16:00:43 +01:00
Elisabeth Henry
98517c243b Make Book::remove_yaml issues a warning when yaml block isn't valid
Previously, it was a debug message, but since it is probable the user
would actually want this to be seen as YAML it's better if the message
is more visible.
2016-03-01 15:42:27 +01:00
Elisabeth Henry
ae2f43193c Make BookOptions::set returns the previous option, if already set
This way, it is possible to display a debug message or a warning when
an option is overriden with a new setting.
2016-03-01 15:33:24 +01:00
Elisabeth Henry
6dd8a970d5 Move BookOptions to its own module, bookoptions.rs 2016-03-01 15:09:50 +01:00
Elisabeth Henry
8b8d847a7d Consider it is a YAML block only if first line is at the beginning of a
doc or preceded by an empty line, to avoid the case where
Foo
---

Bar
---

gets counted as a YAML block. The only ambiguous case left is if you had wanted to make two rules,
but can easily be avoided by using either *** for rules, or by using more dashes.
2016-03-01 04:02:49 +01:00
Elisabeth Henry
fa5393641b Crowbook now ignores YAML blocks (i.e., delimited by two lines containing ---, must contain valid YAML) in Markdown files 2016-03-01 01:28:36 +01:00
Elisabeth Henry
67bc26aaa8 made more clear in debug mode that what is printed is the output of latex/zip command 2016-02-29 01:52:26 +01:00
Elisabeth Henry
127bdae1e5 crowbook no longer crash if it cannot create file specified with --output 2016-02-29 01:39:10 +01:00
Elisabeth Henry
2cb67068c6 book.render_all now does error checking internally and runs all renderer even if first one fails 2016-02-29 01:32:30 +01:00
Elisabeth Henry
9125fa370f added --debug option 2016-02-29 00:44:48 +01:00
Elisabeth Henry
48a672c024 adaptating verbose status to Logger 2016-02-29 00:36:45 +01:00
Elisabeth Henry
2563d997c3 use Logger struct and removed book.debug/println 2016-02-28 17:11:11 +01:00
Elisabeth Henry
cbbabf11e9 moved book options handling to a separate struct, BookOptions 2016-02-27 13:52:43 +01:00
Elisabeth Henry
5ec5924a50 renamed resource.rs to resource_handler.rs 2016-02-27 12:52:25 +01:00
Elisabeth Henry
a523789435 local images now work for pdf and epub outputs 2016-02-27 04:35:38 +01:00
Elisabeth Henry
e8846117f2 started working on a way to get links to .md files working, but it's gonna be a long road 2016-02-26 22:41:30 +01:00
Elisabeth Henry
9ee9e4958d cleaned a bit (hum) book.rs 2016-02-26 19:11:16 +01:00
Elisabeth Henry
8175812f36 added zip.command to book options 2016-02-26 18:51:13 +01:00
Elisabeth Henry
bd2971ab61 no longer change current directory, as it generated problems in multithreaded envs 2016-02-26 17:33:33 +01:00
Elisabeth Henry
f855d74db6 continued documentation 2016-02-26 04:21:20 +01:00
Elisabeth Henry
158142c32e book.rs: added documentation 2016-02-26 02:45:21 +01:00
Elisabeth Henry
0b0da0092e code cleaning and improving documentation 2016-02-26 01:49:38 +01:00
Elisabeth Henry
3381c5d078 added unit test for book 2016-02-26 00:17:03 +01:00
Elisabeth Henry
30262ebc07 binary: added a --print-template option 2016-02-25 15:41:30 +01:00
Elisabeth Henry
770822ac43 Book now supports multiline strings 2016-02-25 15:29:35 +01:00
Elisabeth Henry
0a0f21c6b5 added option to display toc in the document for HTML and PDF output 2016-02-24 20:51:39 +01:00
Elisabeth Henry
7653d2e767 book option numbering is now an i32 instead of a false, 2016-02-23 23:40:41 +01:00
Elisabeth Henry
38db23b8ae set numbering to true by default 2016-02-23 23:29:39 +01:00
Elisabeth Henry
47cb2d1c8a Book now can describe its options 2016-02-23 05:04:50 +01:00
Elisabeth Henry
50cc073b21 added support for end notes 2016-02-23 02:20:11 +01:00
Elisabeth Henry
6218ca91cf refactored Book to use a map instead of 42 fields 2016-02-22 23:21:51 +01:00
Elisabeth Henry
0391153865 cleaner no longer used in parser but in the various renderers 2016-02-22 16:20:47 +01:00
Elisabeth Henry
9ace79f1b5 book now have a set_option method, allowing binary to --set anyone of the book option 2016-02-22 03:23:16 +01:00
Elisabeth Henry
ef26c10c02 updated templates 2016-02-21 19:39:54 +01:00
Elisabeth Henry
f4cb25c8f8 removed verbose option from book config as it only makes sense on the command line 2016-02-21 18:31:13 +01:00
Elisabeth Henry
c5a1fcfe60 warning messages now printed on stderr, and only in verbose 2016-02-21 18:29:16 +01:00
Elisabeth Henry
11c84726b8 fixed some escaping, now allow use output.xx instead of output_xxx in book file 2016-02-21 05:29:40 +01:00
Elisabeth Henry
3accc203d9 fixed latex escaping problem in title 2016-02-21 04:34:54 +01:00
Elisabeth Henry
80e0d50c53 nows tries to render odt if specified in book file 2016-02-21 01:55:16 +01:00
Elisabeth Henry
40b32226cc experimental support for odt 2016-02-21 01:49:58 +01:00
Elisabeth Henry
d474bce3d6 started to work on odt rendering but it's a pain:( 2016-02-20 22:52:10 +01:00
Elisabeth Henry
c6455dd98c added support for chapter whose title is hidden 2016-02-20 19:06:15 +01:00
Elisabeth Henry
06f59b08f8 added options to binary 2016-02-20 16:56:07 +01:00
Elisabeth Henry
2ad66d7286 now supports epub3 (in theory) 2016-02-20 03:41:29 +01:00
Elisabeth Henry
91d99ca9a6 fixed a bug which caused error when crowbook runned on book in same directory 2016-02-20 00:10:31 +01:00
Elisabeth Henry
829746a762 runned clippy, thus some minor corrections 2016-02-19 23:43:16 +01:00
Elisabeth Henry
559cc8fac7 added a way to set epub/html template and css 2016-02-19 22:17:10 +01:00
Elisabeth Henry
90504e2acc added a book_example 2016-02-19 21:35:49 +01:00