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
//! The scrambled copy of a manuscript.
//!
//! An author whose import fails can send a copy of the manuscript with every
//! letter replaced and the structure kept: most import bugs survive, none of
//! the prose does. `scrub` makes the copy, `check` imports the original and
//! the copy and says whether the copy still shows the problem.
//!
//! What a copy keeps and changes:
//!
//! - **Letters** change, one for one: a vowel for a vowel, a consonant for a
//! consonant, an umlaut for an umlaut, ß for ß, upper case for upper case.
//! A word keeps its length, and is replaced the same way wherever it
//! stands in the file (so a title page and the document properties still
//! agree, and a contents entry still matches its heading).
//! - **Everything else** stays: digits, punctuation, quotation marks,
//! dashes, spaces, no-break and zero-width characters, soft hyphens,
//! combining accents, line breaks, markup.
//! - **The words the importer reads** stay, because it decides by them:
//! its heading, section and number words, "END"/"Ende", months, "by"/
//! "von", the starts of dedications and copyright lines, and the function
//! words it counts to tell English from German (`vocab`, `lang`: taken
//! from the importer itself). Heading-type words stay only in short lines
//! and only where the importer reads them; in running text they are
//! replaced like any other word.
//! - **A .docx** is rewritten entry by entry: text in `document.xml`, notes,
//! headers, footers, comments, text boxes and the document properties is
//! replaced in place; every picture becomes a blank one of the same
//! format, pixel size, resolution, colour mode and rotation tag
//! (`image`); every other entry is copied byte for byte.
//! - **Markdown** keeps its front-matter keys and language, link and image
//! targets, footnote labels, fences and attributes.
//!
//! The replacement is deterministic: its seed is a hash of the file, so the
//! same file always gives the same copy (tests are stable) and two files
//! give two different mappings. It is not a cipher: the original letters
//! are not in the copy, only a random choice of the same kind, so nothing
//! can be undone from the copy alone; and without the original there is no
//! seed to find, only a hash of text nobody else has.
//!
//! A file the scrubber cannot read is an error, never a repaired copy.
use Path;
pub use ;
pub use ScrubbedMarkdown;
/// Why a scrambled copy could not be made. The app then offers the
/// original.
/// What kind of manuscript a file is.
/// A scrambled manuscript: the file's bytes, and for Markdown the blank
/// pictures it refers to (see [`ScrubbedMarkdown::images`]); a .docx holds
/// its own.
/// The scrambled copy of a manuscript's bytes. `images` gives the bytes of
/// a picture a Markdown manuscript refers to, by the path written in it
/// (as for `markdown::import`); a .docx does not use it.
/// The scrambled copy of a .docx.
/// The scrambled copy of a Markdown manuscript, with a blank picture for
/// each one the original's import found.