1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-06-07 19:56:15 +02:00

Add language information to codeblocks in .md files

This commit is contained in:
Elisabeth Henry 2016-09-15 22:05:11 +02:00
parent 0f91d24f50
commit 5231ab95f9
3 changed files with 35 additions and 39 deletions

View File

@ -1,12 +1,6 @@
Crowbook
========
```rust
fn test() {
println!("{}", 42);
}
```
[![Build Status](https://travis-ci.org/lise-henry/crowbook.svg?branch=master)](https://travis-ci.org/lise-henry/crowbook)
Render a book written in markdown to HTML, Epub or PDF.
@ -50,7 +44,7 @@ on your machine first; you can
[download and install it here](https://www.rust-lang.org/downloads.html). Once
it is down:
```
```bash
$ cargo install crowbook
```
@ -142,7 +136,7 @@ document.
Crowbook supports inline YAML blocks:
```markdown
```yaml
---
author: Me
title: My title
@ -153,7 +147,7 @@ This is mostly useful when Crowbook is runned with the `--single`
argument (receiving a single Markdown file instead of a book
configuration file). E.g., the following Markdown file:
```
```yaml
---
author: John Doe
title: A book

View File

@ -3,7 +3,7 @@ Arguments
Crowbook can takes a list of arguments:
```bash
```text
Render a markdown book in Epub, PDF or HTML.
USAGE:
@ -29,7 +29,8 @@ ARGS:
Note that Crowbook generates output files relatively to the directory
where <BOOK> is:
```
```bash
$ crowbook foo/bar.book --to pdf --output baz.pdf
```
will thus generate baz.pdf in directory foo and not in current directory.
@ -56,13 +57,13 @@ exists).
### Examples ###
```
```bash
crowbook foo.book --create README.md ChangeLog.md LICENSE.md
```
will generate a file `foo.book` containing:
```
```yaml
author: Your name
title: Your title
lang: en
@ -83,7 +84,7 @@ lang: en
while
```
```bash
crowbook --create README.md ChangeLog.md LICENSE.md
```
@ -92,13 +93,13 @@ will prints the same result, but to stdout (without creating a file).
When `crowbook` is runned with `--create`, it can also uses the
keys/values set by `--set` (see below):
```
```bash
$ crowbook foo.book --create file1.md file2.md --set author "Pierre Dupont" title "Mon œuvre" lang fr
```
will generate a `foo.book` file containing
```
```yaml
author: Pierre Dupont
title: Mon œuvre
lang: fr
@ -119,7 +120,7 @@ This options allows to pass `crowbook` a single Markdown file. This
file can contain an inline YAML block to set some book options. Inline
YAML blocks must start and end with a line with `---` (three dashes). E.g:
```markdown
```yaml
---
author: Joan Doe
title: A short story
@ -133,7 +134,7 @@ This allows to not have to write a `.book` configuration file for a
short story or an article. `crowbook --single foo.md` is rougly equivalent to having a book
configuration file containing:
```markdown
```yaml
! foo.md
```
@ -156,13 +157,13 @@ configuration files are valid as keys. For more information, see
### Examples ###
```
```bash
$ crowbook foo.book --set html.css style.css
```
will override the CSS for HTML generation (the `html.css` key) to `style.css`.
```
```bash
$ crowbook foo.book --set author Foo --title Bar
```
@ -187,7 +188,7 @@ Prints to stdout the built-in template. Useful if you want to
customize the appearance of your document. E.g., if you want to modify
the CSS used for HTML rendering:
```
```bash
$ crowbook --print-template html.css > my_style.css
# edit my_style.css in your favourite editor
$ crowbook my.book --set html.css my_style.css
@ -197,7 +198,7 @@ $ crowbook my.book --set html.css my_style.css
Note that it is possible to use this option in conjonction with
`--set`, though it is currently only useful for EPUB template:
```
```bash
$ crowbook --print-template epub.template --set epub.version 2
# Returns the template for Epub 2 (currently it is the default one)
$ crowbook --print-template epub.template --set epub.version 3
@ -232,14 +233,14 @@ possible to specify a file with the `--output` option.
### Examples ###
```
```bash
crowbook --to html foo.book
```
will generate some HTML, and prints it either to the file specified by
`output.html` in `foo.book`, or to stdout if it is not specified.
```
```bash
crowbook --to pdf --output foo.pdf foo.book
```
@ -256,7 +257,8 @@ Specifies an output file. Only valid when `--to` is used.
Note that Crowbook generates output files relatively to the directory
where `BOOK` is:
```
```bash
$ crowbook foo/bar.book --to pdf --output baz.pdf
```
will thus generate `baz.pdf` in directory `foo` and not in current

View File

@ -8,7 +8,7 @@ but that's besides the scope of this document).
The format is not very complicated. This is an example of it:
```
```yaml
# metadata
author: Joan Doe
title: Some book
@ -46,7 +46,7 @@ There are various options to include a markdown file.
So a typical usage might look like this:
```
```yaml
! copyright.md
- preface.md
# We want first chapter to be Chapter 0 because we are programmers!
@ -108,14 +108,14 @@ to Crowbook. This is
be of the form `key: value`. Note that in most cases you don't have to
put string in quotes, e.g.:
```
```yaml
title: My title
```
It is however possible (and sometimes necessary) to escape some
characters to use quotes around strings:
```
```yaml
title: "My: title!"
```
@ -123,7 +123,7 @@ title: "My: title!"
It is possible to use multiline strings with `>-` and
then indenting the lines that are part of the string:
```
```yaml
title: >-
A
long
@ -369,7 +369,7 @@ one of this option, or Crowbook won't do anything.
Recall that all file paths are relative to the directory where the
config file is, not to the one where you run `crowbook`. So if you set
```
```yaml
output.epub = foo.epub
```
@ -385,7 +385,7 @@ directory.
Crowbook will try to generate each of the `output.xxx` files that are
specified. That means that you'll have to set at least one of those if you want a call to
```
```bash
$ crowbook my.book
```
@ -418,7 +418,7 @@ These two options allow to embed additional files for some formats
A list of files or directories that should be added. It's a
whitespace-separated list, so it can be, e.g.:
```
```yaml
resources.files: font1.otf font2.otf
```
@ -426,14 +426,14 @@ It is also possible to specify a directory (or multiple
directories). So if you have a `fonts` directories containing
`font1.otf` and `font2.otf`,
```
```yaml
resources.files: fonts
```
will be equivalent to:
```
resources.files fonts/font1.otf fonts/font2.otf
```yaml
resources.files: fonts/font1.otf fonts/font2.otf
```
@ -453,7 +453,7 @@ Note that if you pass directories to `resources.files`, the whole
directory would be copied. So assuming `fonts/` contains `font1.otf`
and `font2.otf`
```
```yaml
resources.files: fonts
resources.path: data
```
@ -463,7 +463,7 @@ will copy these two files to `data/fonts/font1.otf` and
Similarly, the whole path of `resources.files` is copied, so
```
```yaml
resources.files: fonts/font1.otf fonts/font2.otf
```
@ -488,7 +488,7 @@ and turns numbering on for all headers.
A string that will be used for chapter titles. You can use `{{number}}` and
`{{title}}` in this string, e.g.:
```
```yaml
numbering_template: "Chapter {{number}} {{title}}"
```