-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanuscript-counters.css
217 lines (206 loc) · 9.02 KB
/
manuscript-counters.css
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/* Manuscript via CSS v2.0 — counters and automated titles
*
* This stylesheet does two things:
* - counts up all the parts, chapters, and scenes and the count of each depth
* of these sections. (Limited to a depth of 5.)
* - enables you to turn on automated title strings. In lieu of page numbers,
* you can turn on automated titles so that reviewers have a navigational
* means of referencing a section in their critique. You can automate
* appending a manuscript tree structure value the titles. Example.
* The third scene in the second chapter would have a value of `Scene 2.3`.
* DEFAULT behavior: SectionName n.n.n.n
*
* How to use . . .
*
* Import this stylesheet after you import `manuscript.css`. Then either leave
* the defaults as they are or turn on/off these variables to generate the
* title string you want. You turn on functionality by `unset`ing various
* `-off` switches in your markdown. You turn them off by setting their values
* to "".
* `--m-autotitle-name-off` -- (default is unset/ON!) adds "Part", "Chapter",
* "Scene" automatically added to the string.
* `--m-autotitle-depth-off` -- (default is ""/off) appends the tree
* location reference (dot-deliminated numbers).
* `--m-autotitle-leaf-off` -- (default is unset/ON!) unset this to only
* append the leaf-node count: Part 1, Part 2, Chapter 1, Scene 1 etc.
* (Don't turn on both -depth-off and -leaf-off.)
*
* `--m-autotitle-for-part-off` -- (default is unset/ON!) append to the part
* titles?
* `--m-autotitle-for-chapter-off` -- (default is unset/ON!) append to the
* chapter titles?
* `--m-autotitle-for-scene-off` -- (default is unset/ON!) append to the
* scene titles?
*
* `--m-autotitle-tally-off` -- (default is ""/off) unset this if you want
* excessive information that includes the total cummulative counts for
* part, chapters, & scenes. I don't recommend using this.
*
* Finally, Anywhere you want to see the automated enumeration of your
* manuscript part, chapter, or scene, you simply add an `m-header` block to
* the section of interest with a # included (title). The string will be added
* to that title. If a section doesn't have that .m-header and title # in your
* markdown, a title will not be shown for that section.
*
* (note, I set the switches below for demonstrative purposes. They are set to
* their default values here.)
*
* <style>
* @import "../manuscript.css";
* @import "../manuscript-counters.css";
* :root {
* --m-append-name-off: unset;
* --m-append-depth-off: "";
* --m-autotitle-leaf-off: unset;
* --m-autotitle-tally-off: "";
* --m-dinkus: unset;
* }
* </style>
*
* . . . the beginning of your document . . .
*
* <section class="m-chapter">
* <div class="m-header">
*
* #
*
* </div>
*
* <section class="m-scene">
* <div class="m-header">
*
* #
*
* </div>
*
* . . . the rest of your document . . .
*
*
* Note. In the example above, I also unset `--m-dinkus`. I do that when I have
* scene titles. The existence of scene titles replaces the purpose of
* the dinkus.
*
* Copyright (c) Todd Warner <t0dd@protonmail.com>
* This work is licensed under Attribution 4.0 International. To view a copy
* of this license, visit http://creativecommons.org/licenses/by/4.0/
*/
:root {
/* "" = off -and- unset = on. */
--m-autotitle-name-off: unset;
--m-autotitle-depth-off: "";
--m-autotitle-leaf-off: unset;
--m-autotitle-tally-off: "";
--m-autotitle-for-part-off: unset;
--m-autotitle-for-chapter-off: unset;
--m-autotitle-for-scene-off: unset;
/* --- do not touch these --- */
--_m-autotitle-tally: " (p" counter(npart) ", c" counter(nchapter) ", s" counter(nscene) ")";
--_m-autotitle1:
var(--m-autotitle-leaf-off, " " counter(nsection1))
var(--m-autotitle-depth-off, " " counter(nsection1))
var(--m-autotitle-tally-off, " " var(--_m-autotitle-tally));
--_m-autotitle2:
var(--m-autotitle-leaf-off, " " counter(nsection2))
var(--m-autotitle-depth-off, " " counter(nsection1) "." counter(nsection2))
var(--m-autotitle-tally-off, " " var(--_m-autotitle-tally));
--_m-autotitle3:
var(--m-autotitle-leaf-off, " " counter(nsection3))
var(--m-autotitle-depth-off, " " counter(nsection1) "." counter(nsection2) "." counter(nsection3))
var(--m-autotitle-tally-off, " " var(--_m-autotitle-tally));
--_m-autotitle4:
var(--m-autotitle-leaf-off, " " counter(nsection4))
var(--m-autotitle-depth-off, " " counter(nsection1) "." counter(nsection2) "." counter(nsection3) "." counter(nsection4))
var(--m-autotitle-tally-off, " " var(--_m-autotitle-tally));
--_m-autotitle5:
var(--m-autotitle-leaf-off, " " counter(nsection5))
var(--m-autotitle-depth-off, " " counter(nsection1) "." counter(nsection2) "." counter(nsection3) "." counter(nsection4) "." counter(nsection5))
var(--m-autotitle-tally-off, " " var(--_m-autotitle-tally));
}
/* Initialize counters for all the major manuscript components. */
#manuscript { counter-reset: npage npart nchapter nscene
nsection nsection1 nsection2 nsection3 nsection4; }
#manuscript > section { counter-reset: nsection2; }
#manuscript > section > section { counter-reset: nsection3; }
#manuscript > section > section > section { counter-reset: nsection4; }
#manuscript > section { --_m-autotitle: var(--_m-autotitle1); }
#manuscript > section > section { --_m-autotitle: var(--_m-autotitle2); }
#manuscript > section > section > section { --_m-autotitle: var(--_m-autotitle3); }
#manuscript > section > section > section > section { --_m-autotitle: var(--_m-autotitle4); }
#manuscript > section > section > section > section > section { --_m-autotitle: var(--_m-autotitle5); }
/* non-scene tally of all sections, and each section depth
* This should always be overriden by the new couple blocks of logic unless we
* come up with a new section variety. - leaving it in for now. */
#manuscript > section::before {
counter-increment: nsection nsection1; content: "";
}
#manuscript > section > section::before {
counter-increment: nsection nsection2; content: "";
}
#manuscript > section > section > section::before {
counter-increment: nsection nsection3; content: "";
}
#manuscript > section > section > section > section::before {
counter-increment: nsection nsection4; content: "";
}
#manuscript > section > section > section > section > section::before {
counter-increment: nsection nsection5; content: "";
}
/* tally of all m-parts, all sections, and each section depth */
/* The specificity of this will override the logic above if we are operating
* on an m-part block */
#manuscript > section.m-part::before {
counter-increment: npart nsection nsection1; content: "";
}
#manuscript > section > section.m-part::before {
counter-increment: npart nsection nsection2; content: "";
}
#manuscript > section > section > section.m-part::before {
counter-increment: npart nsection nsection3; content: "";
}
/* tally of all m-chapters, all sections, and each section depth */
/* The specificity of this will override the logic above if we are operating
* on an m-chapter block */
#manuscript > section.m-chapter::before {
counter-increment: nchapter nsection nsection1; content: "";
}
#manuscript > section > section.m-chapter::before {
counter-increment: nchapter nsection nsection2; content: "";
}
#manuscript > section > section > section.m-chapter::before {
counter-increment: nchapter nsection nsection3; content: "";
}
#manuscript > section > section > section > section.m-chapter::before {
counter-increment: nchapter nsection nsection4; content: "";
}
/* tally of all m-scenes, all sections, and each section depth */
/* The specificity of this will override the logic above if we are operating
* on an m-scene block */
#manuscript > section.m-scene::before {
counter-increment: nscene nsection nsection1; content: "";
}
#manuscript > section > section.m-scene::before {
counter-increment: nscene nsection nsection2; content: "";
}
#manuscript > section > section > section.m-scene::before {
counter-increment: nscene nsection nsection3; content: "";
}
#manuscript > section > section > section > section.m-scene::before {
counter-increment: nscene nsection nsection4; content: "";
}
#manuscript > section > section > section > section > section.m-scene::before {
counter-increment: nscene nsection nsection5; content: "";
}
/* build the string to append to a title */
#manuscript section.m-part {
--m-autotitle: var(--m-autotitle-for-part-off, var(--m-autotitle-name-off, "Part ") var(--_m-autotitle));
}
#manuscript section.m-chapter {
--m-autotitle: var(--m-autotitle-for-chapter-off, var(--m-autotitle-name-off, "Chapter ") var(--_m-autotitle));
}
#manuscript section.m-scene {
--m-autotitle: var(--m-autotitle-for-scene-off, var(--m-autotitle-name-off, "Scene ") var(--_m-autotitle));
}
/* application f the autotitle title string */
#manuscript section > .m-header > h1::after {
content: var(--m-autotitle);
}