1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! What a front end hands to the assembler: a book in the terms of its
//! source.
//!
//! A front end parses one format and builds a [`Draft`]. It decides nothing
//! about the mbook file: no chapter paths, no picture paths, no tables. The
//! contract between a front end and the assembler is this:
//!
//! - **Sections.** One [`Section`] per top-level division of the source, in
//! reading order. Its `name` is unique in the draft, is not empty and does
//! not contain `#` or `:`.
//! - **Markdown.** The text of a section is Markdown of the dialect of
//! RFC 0001. Text taken from the source is escaped with
//! [`markdown::escape`](crate::markdown::escape). Raw HTML that slips
//! through is removed by the assembler, with a warning.
//! - **Link targets.** An element of the source that a link may lead to is
//! marked in front of its block with an anchor definition and an empty
//! line: `format!("{}\n\n", markdown::definition(&markdown::anchor_name(id)))`,
//! where `id` is the identifier the element has in the source. The
//! assembler keeps the marks that a link uses and removes the others.
//! - **Links into the book.** `format!("[{text}]{}", markdown::target(&destination, None))`,
//! where `text` is Markdown already and `destination` comes from
//! [`markdown::destination`](crate::markdown::destination): the name of
//! the target section and, for a marked element, its identifier. An
//! address outside the book is written as it is.
//! - **Pictures.** `markdown::image(alt, &markdown::encoded_path(name), title)`,
//! where `name` is the `name` of a [`SourcePicture`] of the draft. A
//! picture alone in a paragraph is a figure, and `title` is its caption.
//! Pictures are handed over as the source has them; the assembler encodes
//! them.
//! - **Footnotes.** A note is `[^label]` at its reference and
//! `[^label]: text` in the same section.
//! - **Outline.** When the source has a table of contents of its own, one
//! [`OutlineEntry`] per item, its target built like the destination of a
//! link.
//! - **Landmarks.** When the source lists notable places of its own (the
//! landmarks of EPUB 3, the guide of EPUB 2), one [`DraftLandmark`] per
//! place, with a kind of RFC 0001 and a target built like the destination
//! of a link.
//! - **Losses.** Whatever a front end cannot keep is a
//! [`Warning`] in the draft, made with `Warning::new(kind, section_name)`.
use crateWarning;
/// A book as its source describes it.
pub
/// The metadata of a source. A value the format does not allow is left out
/// by the assembler, with a warning.
pub
/// One top-level division of a source.
pub
/// One picture of a source.
pub
/// A picture as a front end has it.
pub
/// One entry of the table of contents of a source.
pub
/// One notable place of a source: the start of its text, its index, …
pub