mint 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -26
- data/README.md +138 -95
- data/bin/mint +2 -81
- data/config/templates/base/navigation.css +136 -0
- data/config/templates/base/print.css +152 -0
- data/config/templates/{reset.css → base/reset.css} +1 -1
- data/config/templates/base/style.css +117 -137
- data/config/templates/base/utilities.css +136 -0
- data/config/templates/base/variables.css +124 -0
- data/config/templates/basic/style.css +151 -0
- data/config/templates/default/layout.erb +33 -3
- data/config/templates/default/style.css +95 -164
- data/config/templates/magazine/style.css +383 -0
- data/config/templates/nord/style.css +105 -220
- data/config/templates/nord-dark/style.css +82 -263
- data/lib/mint/commandline/parse.rb +144 -0
- data/lib/mint/commandline/publish.rb +46 -0
- data/lib/mint/commandline/run.rb +30 -0
- data/lib/mint/config.rb +162 -0
- data/lib/mint/{css.rb → css_dsl.rb} +9 -9
- data/lib/mint/css_parser.rb +96 -0
- data/lib/mint/document.rb +251 -348
- data/lib/mint/document_tree.rb +163 -0
- data/lib/mint/exceptions.rb +2 -3
- data/lib/mint/helpers.rb +23 -180
- data/lib/mint/layout.rb +26 -9
- data/lib/mint/renderers/css_renderer.rb +32 -0
- data/lib/mint/renderers/erb_renderer.rb +11 -0
- data/lib/mint/renderers/markdown_renderer.rb +45 -0
- data/lib/mint/style.rb +21 -31
- data/lib/mint/template.rb +30 -0
- data/lib/mint/version.rb +1 -1
- data/lib/mint/workspace.rb +171 -0
- data/lib/mint.rb +44 -12
- data/man/mint.1 +88 -47
- data/spec/cli/README.md +13 -13
- data/spec/cli/argument_parsing_spec.rb +103 -131
- data/spec/cli/bin_integration_spec.rb +23 -243
- data/spec/cli/full_workflow_integration_spec.rb +99 -442
- data/spec/cli/original_style_integration_spec.rb +58 -0
- data/spec/cli/publish_workflow_spec.rb +72 -70
- data/spec/commandline_path_integration_spec.rb +230 -0
- data/spec/config_file_integration_spec.rb +362 -0
- data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
- data/spec/css_parser_spec.rb +207 -0
- data/spec/document_spec.rb +37 -242
- data/spec/flattened_path_spec.rb +150 -0
- data/spec/layout_spec.rb +42 -3
- data/spec/mint_spec.rb +22 -217
- data/spec/path_handling_spec.rb +237 -0
- data/spec/run_cli_tests.rb +1 -1
- data/spec/spec_helper.rb +3 -10
- data/spec/style_spec.rb +31 -56
- data/spec/support/cli_helpers.rb +7 -10
- data/spec/support/matchers.rb +1 -1
- data/spec/template_spec.rb +31 -0
- data/spec/workspace_spec.rb +177 -0
- metadata +78 -93
- data/bin/mint-epub +0 -20
- data/config/templates/default/css/style.css +0 -205
- data/config/templates/garden/layout.erb +0 -38
- data/config/templates/garden/style.css +0 -303
- data/config/templates/newspaper/layout.erb +0 -16
- data/config/templates/nord/layout.erb +0 -11
- data/config/templates/nord-dark/layout.erb +0 -11
- data/config/templates/protocol/layout.erb +0 -9
- data/config/templates/protocol/style.css +0 -25
- data/config/templates/zen/layout.erb +0 -11
- data/config/templates/zen/style.css +0 -114
- data/lib/mint/command_line.rb +0 -360
- data/lib/mint/css_template.rb +0 -37
- data/lib/mint/markdown_template.rb +0 -47
- data/lib/mint/mint.rb +0 -313
- data/lib/mint/plugin.rb +0 -136
- data/lib/mint/plugins/epub.rb +0 -293
- data/lib/mint/resource.rb +0 -101
- data/plugins/templates/epub/layouts/container.haml +0 -5
- data/plugins/templates/epub/layouts/content.haml +0 -35
- data/plugins/templates/epub/layouts/layout.haml +0 -6
- data/plugins/templates/epub/layouts/title.haml +0 -11
- data/plugins/templates/epub/layouts/toc.haml +0 -26
- data/spec/cli/configuration_management_spec.rb +0 -363
- data/spec/cli/template_management_spec.rb +0 -300
- data/spec/helpers_spec.rb +0 -249
- data/spec/plugin_spec.rb +0 -449
- data/spec/resource_spec.rb +0 -135
@@ -1,339 +1,158 @@
|
|
1
|
-
|
1
|
+
/* Import base Nord template and override for dark theme */
|
2
|
+
@import "../nord/style.css";
|
2
3
|
|
4
|
+
/* Nord dark theme overrides */
|
3
5
|
:root {
|
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
|
-
|
6
|
+
/* Dark theme semantic color mappings */
|
7
|
+
--color-text: var(--nord6); /* Light text */
|
8
|
+
--color-text-subtle: var(--nord4); /* Subtle light text */
|
9
|
+
--color-text-muted: var(--nord5); /* Muted light text */
|
10
|
+
--color-background: var(--nord1); /* Dark background */
|
11
|
+
--color-surface: var(--nord2); /* Slightly lighter dark surface */
|
12
|
+
--color-surface-subtle: var(--nord3); /* Even lighter surface for contrast */
|
13
|
+
--color-border: var(--nord3); /* Dark borders */
|
14
|
+
--color-accent: var(--nord8); /* Light blue accent */
|
15
|
+
--color-accent-hover: var(--nord7); /* Teal accent hover */
|
16
|
+
--color-accent-subtle: rgba(136, 192, 208, 0.15);
|
17
|
+
|
18
|
+
/* Component colors for dark theme */
|
19
|
+
--color-code-bg: var(--nord3); /* Lighter dark background */
|
20
|
+
--color-code-text: var(--nord13); /* Yellow code text for visibility */
|
21
|
+
--color-pre-bg: var(--nord2); /* Lighter dark background */
|
22
|
+
--color-pre-text: var(--nord6); /* Light pre code text */
|
23
|
+
--color-quote-bg: var(--nord2); /* Lighter dark background for better contrast */
|
24
|
+
--color-quote-text: var(--nord4);
|
25
|
+
--color-quote-border: var(--nord14); /* Green accent border */
|
26
|
+
|
27
|
+
/* Navigation dark theme colors */
|
28
|
+
--color-nav-bg: var(--nord0);
|
29
|
+
--color-nav-text: var(--nord4);
|
30
|
+
--color-nav-text-hover: var(--nord6);
|
31
|
+
--color-nav-text-active: var(--nord8);
|
32
|
+
--color-nav-bg-hover: var(--nord2);
|
33
|
+
--color-nav-bg-active: rgba(136, 192, 208, 0.15);
|
34
|
+
--color-nav-border: var(--nord3);
|
35
|
+
--color-nav-border-active: var(--nord8);
|
36
|
+
|
37
|
+
/* Table dark theme colors */
|
38
|
+
--color-table-bg: var(--nord2); /* Dark table background */
|
39
|
+
--color-table-header-bg: var(--nord3); /* Slightly lighter header background */
|
40
|
+
--color-table-header-text: var(--nord8); /* Light blue header text */
|
41
|
+
--color-table-border: var(--nord3);
|
42
|
+
--color-table-stripe: transparent;
|
43
|
+
--color-table-hover: rgba(143, 188, 187, 0.1);
|
44
|
+
}
|
45
|
+
|
46
|
+
/* Override body background for full dark theme */
|
41
47
|
body {
|
42
|
-
|
43
|
-
color: var(--
|
44
|
-
line-height: 1.5;
|
45
|
-
background-color: var(--nord-background);
|
46
|
-
font-weight: 400;
|
47
|
-
letter-spacing: -0.005em;
|
48
|
-
font-feature-settings: "liga" 1, "kern" 1;
|
48
|
+
background-color: var(--color-background) !important;
|
49
|
+
color: var(--color-text) !important;
|
49
50
|
}
|
50
51
|
|
52
|
+
/* Override heading colors for dark theme contrast */
|
51
53
|
h1, h2, h3, h4, h5, h6 {
|
52
|
-
|
53
|
-
color: var(--nord-text);
|
54
|
-
letter-spacing: -0.02em;
|
55
|
-
}
|
56
|
-
|
57
|
-
h1 {
|
58
|
-
font-size: calc(var(--screen-font-size) * 1.8);
|
59
|
-
margin-top: calc(var(--screen-unit) * 2);
|
60
|
-
margin-bottom: calc(var(--screen-unit) * 1.5);
|
61
|
-
line-height: 1.3;
|
62
|
-
color: var(--nord6);
|
63
|
-
}
|
64
|
-
|
65
|
-
h2 {
|
66
|
-
font-size: calc(var(--screen-font-size) * 1.4);
|
67
|
-
margin-top: calc(var(--screen-unit) * 1.5);
|
68
|
-
margin-bottom: calc(var(--screen-unit) * 0.75);
|
69
|
-
line-height: 1.4;
|
70
|
-
color: var(--nord5);
|
71
|
-
}
|
72
|
-
|
73
|
-
h3 {
|
74
|
-
font-size: calc(var(--screen-font-size) * 1.2);
|
75
|
-
margin-top: calc(var(--screen-unit) * 1.25);
|
76
|
-
margin-bottom: calc(var(--screen-unit) * 0.5);
|
77
|
-
line-height: 1.4;
|
78
|
-
color: var(--nord4);
|
79
|
-
}
|
80
|
-
|
81
|
-
h4, h5, h6 {
|
82
|
-
font-size: calc(var(--screen-font-size) * 1.05);
|
83
|
-
margin-top: calc(var(--screen-unit) * 1);
|
84
|
-
margin-bottom: calc(var(--screen-unit) * 0.25);
|
85
|
-
line-height: 1.4;
|
86
|
-
color: var(--nord4);
|
87
|
-
}
|
88
|
-
|
89
|
-
p {
|
90
|
-
margin: calc(var(--screen-unit) * 0.75) 0;
|
91
|
-
}
|
92
|
-
|
93
|
-
blockquote {
|
94
|
-
border-left: 3px solid var(--nord8);
|
95
|
-
padding-left: calc(var(--screen-unit) * 1);
|
96
|
-
margin-left: 0;
|
97
|
-
font-style: italic;
|
98
|
-
color: var(--nord-text-subtle);
|
99
|
-
background-color: rgba(59, 66, 82, 0.3);
|
100
|
-
padding: calc(var(--screen-unit) * 0.75) calc(var(--screen-unit) * 1);
|
101
|
-
border-radius: 0 4px 4px 0;
|
54
|
+
color: var(--color-text);
|
102
55
|
}
|
103
56
|
|
57
|
+
/* Enhanced code styling for dark theme */
|
104
58
|
code {
|
105
|
-
|
106
|
-
font-size: calc(var(--screen-font-size) * 0.9);
|
107
|
-
background-color: var(--nord2);
|
108
|
-
color: var(--nord6);
|
109
|
-
padding: 0.15em 0.4em;
|
110
|
-
border-radius: 4px;
|
111
|
-
font-weight: 500;
|
112
|
-
letter-spacing: 0;
|
59
|
+
border: 1px solid var(--nord10);
|
113
60
|
}
|
114
61
|
|
115
62
|
pre {
|
116
|
-
|
117
|
-
border: 1px solid var(--nord-border);
|
118
|
-
border-radius: 8px;
|
119
|
-
padding: calc(var(--screen-unit) * 1);
|
120
|
-
overflow-x: auto;
|
121
|
-
margin: calc(var(--screen-unit) * 1) 0;
|
122
|
-
}
|
123
|
-
|
124
|
-
pre code {
|
125
|
-
background-color: transparent;
|
126
|
-
padding: 0;
|
127
|
-
border-radius: 0;
|
128
|
-
font-size: calc(var(--screen-font-size) * 0.85);
|
129
|
-
color: var(--nord6);
|
130
|
-
}
|
131
|
-
|
132
|
-
a:link, a:visited {
|
133
|
-
color: var(--nord-accent);
|
134
|
-
text-decoration: none;
|
135
|
-
border-bottom: 1px solid transparent;
|
136
|
-
transition: all 0.2s ease;
|
137
|
-
}
|
138
|
-
|
139
|
-
a:hover {
|
140
|
-
color: var(--nord7);
|
141
|
-
border-bottom-color: var(--nord7);
|
142
|
-
}
|
143
|
-
|
144
|
-
strong {
|
145
|
-
font-weight: 600;
|
146
|
-
color: var(--nord6);
|
63
|
+
border: 1px solid var(--nord9);
|
147
64
|
}
|
148
65
|
|
149
|
-
|
150
|
-
|
151
|
-
color: var(--
|
152
|
-
|
153
|
-
|
154
|
-
ul, ol {
|
155
|
-
margin: calc(var(--screen-unit) * 0.75) 0;
|
156
|
-
padding-left: calc(var(--screen-unit) * 1.5);
|
157
|
-
}
|
158
|
-
|
159
|
-
li {
|
160
|
-
margin: calc(var(--screen-unit) * 0.25) 0;
|
66
|
+
/* Horizontal rule styling for dark theme */
|
67
|
+
hr {
|
68
|
+
background-color: var(--nord7);
|
69
|
+
height: 2px;
|
161
70
|
}
|
162
71
|
|
72
|
+
/* Table enhancements for dark theme */
|
163
73
|
table {
|
164
|
-
border-collapse: collapse;
|
165
|
-
margin: calc(var(--screen-unit) * 1) 0;
|
166
|
-
width: 100%;
|
167
|
-
background-color: var(--nord-surface);
|
168
|
-
border-radius: 6px;
|
169
|
-
overflow: hidden;
|
170
74
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
171
75
|
}
|
172
76
|
|
173
|
-
th
|
174
|
-
|
175
|
-
text-align: left;
|
176
|
-
border-bottom: 1px solid var(--nord-border);
|
77
|
+
th {
|
78
|
+
border-bottom: 2px solid var(--nord7);
|
177
79
|
}
|
178
80
|
|
179
|
-
|
180
|
-
|
181
|
-
font-weight: 600;
|
182
|
-
color: var(--nord6);
|
183
|
-
font-size: calc(var(--screen-font-size) * 0.9);
|
184
|
-
text-transform: uppercase;
|
185
|
-
letter-spacing: 0.05em;
|
81
|
+
td {
|
82
|
+
border-bottom: 1px solid var(--nord3);
|
186
83
|
}
|
187
84
|
|
188
|
-
|
189
|
-
|
85
|
+
/* Ensure all text elements have proper light colors */
|
86
|
+
p, li, td, dd, dt {
|
87
|
+
color: var(--color-text) !important;
|
190
88
|
}
|
191
89
|
|
192
|
-
|
193
|
-
|
90
|
+
/* Links for dark theme */
|
91
|
+
a {
|
92
|
+
color: var(--nord8) !important;
|
194
93
|
}
|
195
94
|
|
196
|
-
|
197
|
-
|
198
|
-
height: 1px;
|
199
|
-
background-color: var(--nord-border);
|
200
|
-
margin: calc(var(--screen-unit) * 2) 0;
|
95
|
+
a:hover {
|
96
|
+
color: var(--nord7) !important;
|
201
97
|
}
|
202
98
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
padding: calc(var(--screen-unit) * 3) calc(var(--screen-unit) * 4);
|
207
|
-
border: 1px solid var(--nord-border);
|
208
|
-
background-color: var(--nord-surface);
|
209
|
-
box-shadow:
|
210
|
-
0 4px 6px rgba(0, 0, 0, 0.2),
|
211
|
-
0 10px 20px rgba(0, 0, 0, 0.3);
|
212
|
-
border-radius: 8px;
|
99
|
+
/* Lists for dark theme */
|
100
|
+
ul, ol {
|
101
|
+
color: var(--color-text);
|
213
102
|
}
|
214
103
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
padding: calc(var(--screen-unit) * 2) calc(var(--screen-unit) * 2);
|
219
|
-
border-radius: 0;
|
220
|
-
box-shadow: none;
|
221
|
-
border: none;
|
222
|
-
}
|
104
|
+
/* Navigation directory names */
|
105
|
+
#navigation .directory-name {
|
106
|
+
color: var(--nord5);
|
223
107
|
}
|
224
108
|
|
109
|
+
/* Print styles - force light theme for printing */
|
225
110
|
@media print {
|
226
|
-
@page {
|
227
|
-
margin: 1in;
|
228
|
-
size: letter;
|
229
|
-
}
|
230
|
-
|
231
|
-
:root {
|
232
|
-
--print-font-size: 11pt;
|
233
|
-
--print-line-height: 16pt;
|
234
|
-
--screen-font-size: var(--print-font-size);
|
235
|
-
--screen-line-height: var(--print-line-height);
|
236
|
-
--screen-unit: var(--print-line-height);
|
237
|
-
}
|
238
|
-
|
239
111
|
body {
|
240
112
|
background-color: white !important;
|
241
113
|
color: #000 !important;
|
242
|
-
font-size: var(--print-font-size) !important;
|
243
|
-
line-height: var(--print-line-height) !important;
|
244
|
-
}
|
245
|
-
|
246
|
-
#container {
|
247
|
-
box-shadow: none !important;
|
248
|
-
border: none !important;
|
249
|
-
border-radius: 0 !important;
|
250
|
-
margin: 0 !important;
|
251
|
-
padding: 0 !important;
|
252
|
-
max-width: none !important;
|
253
|
-
background-color: white !important;
|
254
114
|
}
|
255
115
|
|
256
116
|
h1, h2, h3, h4, h5, h6 {
|
257
117
|
color: #000 !important;
|
258
|
-
page-break-after: avoid;
|
259
|
-
}
|
260
|
-
|
261
|
-
h1 {
|
262
|
-
font-size: 18pt !important;
|
263
|
-
line-height: 22pt !important;
|
264
|
-
}
|
265
|
-
|
266
|
-
h2 {
|
267
|
-
font-size: 14pt !important;
|
268
|
-
line-height: 18pt !important;
|
269
118
|
}
|
270
119
|
|
271
|
-
|
272
|
-
|
273
|
-
line-height: 16pt !important;
|
274
|
-
}
|
275
|
-
|
276
|
-
h4, h5, h6 {
|
277
|
-
font-size: 11pt !important;
|
278
|
-
line-height: 16pt !important;
|
279
|
-
}
|
280
|
-
|
281
|
-
p, li {
|
282
|
-
orphans: 3;
|
283
|
-
widows: 3;
|
284
|
-
}
|
285
|
-
|
286
|
-
blockquote, pre {
|
287
|
-
page-break-inside: avoid;
|
120
|
+
p, li, td, dd, dt {
|
121
|
+
color: #000 !important;
|
288
122
|
}
|
289
123
|
|
290
124
|
a {
|
291
125
|
color: #000 !important;
|
292
|
-
text-decoration: underline !important;
|
293
126
|
}
|
294
127
|
|
295
128
|
code {
|
296
129
|
background-color: #f5f5f5 !important;
|
297
|
-
border-radius: 0 !important;
|
298
130
|
color: #000 !important;
|
299
|
-
|
131
|
+
border: 1px solid #ddd !important;
|
300
132
|
}
|
301
133
|
|
302
134
|
pre {
|
303
135
|
background-color: #f8f8f8 !important;
|
304
136
|
border: 1px solid #ddd !important;
|
305
|
-
border-radius: 0 !important;
|
306
137
|
color: #000 !important;
|
307
138
|
}
|
308
139
|
|
309
|
-
pre code {
|
310
|
-
background-color: transparent !important;
|
311
|
-
font-size: 9pt !important;
|
312
|
-
}
|
313
|
-
|
314
140
|
table {
|
315
|
-
border-collapse: collapse !important;
|
316
|
-
border-radius: 0 !important;
|
317
141
|
background-color: white !important;
|
318
142
|
box-shadow: none !important;
|
319
143
|
}
|
320
144
|
|
321
145
|
th, td {
|
322
|
-
border: 1px solid #000 !important;
|
323
146
|
color: #000 !important;
|
147
|
+
border: 1px solid #000 !important;
|
324
148
|
}
|
325
149
|
|
326
150
|
th {
|
327
151
|
background-color: #f0f0f0 !important;
|
328
152
|
}
|
329
153
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
img {
|
336
|
-
max-width: 100% !important;
|
337
|
-
page-break-inside: avoid;
|
154
|
+
blockquote {
|
155
|
+
color: #333 !important;
|
156
|
+
background-color: transparent !important;
|
338
157
|
}
|
339
158
|
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "optparse"
|
3
|
+
require "active_support/core_ext/object/blank"
|
4
|
+
|
5
|
+
require_relative "../config"
|
6
|
+
|
7
|
+
module Mint
|
8
|
+
module Commandline
|
9
|
+
# Parses ARGV using OptionParser, mutating ARGV
|
10
|
+
#
|
11
|
+
# @param [Array] argv a list of arguments to parse
|
12
|
+
# @return [Array] a list that contains the command, a help message,
|
13
|
+
# parsed config, and selected scopes
|
14
|
+
def self.parse!(argv)
|
15
|
+
commandline_options = {}
|
16
|
+
|
17
|
+
parser = OptionParser.new do |cli|
|
18
|
+
cli.banner = "Usage: mint [command] files [options]"
|
19
|
+
|
20
|
+
cli.on "-h", "--help", "Show this help message" do
|
21
|
+
commandline_options[:help] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
cli.on "-v", "--verbose", "Show verbose output" do
|
25
|
+
commandline_options[:verbose] = true
|
26
|
+
end
|
27
|
+
|
28
|
+
cli.on "-t", "--template TEMPLATE", "Specify a template by name (default: default)" do |t|
|
29
|
+
commandline_options[:layout_name] = t
|
30
|
+
commandline_options[:style_name] = t
|
31
|
+
end
|
32
|
+
|
33
|
+
cli.on "-l", "--layout LAYOUT", "Specify a layout by name (default: default)" do |l|
|
34
|
+
commandline_options[:layout_name] = l
|
35
|
+
end
|
36
|
+
|
37
|
+
cli.on "-s", "--style STYLE", "Specify a style by name (default: default)" do |s|
|
38
|
+
commandline_options[:style_name] = s
|
39
|
+
end
|
40
|
+
|
41
|
+
cli.on "-w", "--working-dir WORKING_DIR", "Specify a working directory outside the current directory (default: current directory)" do |w|
|
42
|
+
commandline_options[:working_directory] = Pathname.new w
|
43
|
+
end
|
44
|
+
|
45
|
+
cli.on "-o", "--output-file FORMAT", "Specify the output file format with substitutions: \%{name}, \%{original_ext}, \%{ext} (default: \%{name}.\%{ext})" do |o|
|
46
|
+
commandline_options[:output_file_format] = o
|
47
|
+
end
|
48
|
+
|
49
|
+
cli.on "-d", "--destination DESTINATION", "Specify a destination directory, relative to the root (default: current directory)" do |d|
|
50
|
+
commandline_options[:destination_directory] = Pathname.new d
|
51
|
+
end
|
52
|
+
|
53
|
+
cli.on "-m", "--style-mode MODE", ["inline", "external", "original"], "Specify how styles are included (inline, external, original) (default: inline)" do |mode|
|
54
|
+
commandline_options[:style_mode] = mode.to_sym
|
55
|
+
end
|
56
|
+
|
57
|
+
cli.on "--style-destination DESTINATION", "Create stylesheet in specified directory (relative to --destination) and link it" do |destination|
|
58
|
+
commandline_options[:style_mode] = :external
|
59
|
+
commandline_options[:style_destination_directory] = destination
|
60
|
+
end
|
61
|
+
|
62
|
+
cli.on "--preserve-structure", "Preserve source directory structure in destination (default: true)" do
|
63
|
+
commandline_options[:preserve_structure] = true
|
64
|
+
end
|
65
|
+
|
66
|
+
cli.on "--no-preserve-structure", "Don't preserve source directory structure in destination" do
|
67
|
+
commandline_options[:preserve_structure] = false
|
68
|
+
end
|
69
|
+
|
70
|
+
cli.on "--navigation", "Make navigation information available to layout, so layout can show a navigation panel (default: false)" do
|
71
|
+
commandline_options[:navigation] = true
|
72
|
+
end
|
73
|
+
|
74
|
+
cli.on "--no-navigation", "Don't make navigation information available to layout" do
|
75
|
+
commandline_options[:navigation] = false
|
76
|
+
end
|
77
|
+
|
78
|
+
cli.on "--autodrop", "Automatically drop common directory levels from output file paths (default: true)" do
|
79
|
+
commandline_options[:autodrop] = true
|
80
|
+
end
|
81
|
+
|
82
|
+
cli.on "--no-autodrop", "Don't automatically drop common directory levels from output file paths" do
|
83
|
+
commandline_options[:autodrop] = false
|
84
|
+
end
|
85
|
+
|
86
|
+
cli.on "--navigation-depth DEPTH", Integer, "Maximum depth to show in navigation (default: 3)" do |depth|
|
87
|
+
commandline_options[:navigation_depth] = depth
|
88
|
+
end
|
89
|
+
|
90
|
+
cli.on "--navigation-title TITLE", "Set the title for the navigation panel" do |title|
|
91
|
+
commandline_options[:navigation_title] = title
|
92
|
+
end
|
93
|
+
|
94
|
+
cli.on "--insert-title-heading", "Insert the document's title as an H1 heading into the document content" do
|
95
|
+
commandline_options[:insert_title_heading] = true
|
96
|
+
end
|
97
|
+
|
98
|
+
cli.on "--no-insert-title-heading", "Don't insert title as H1 heading" do
|
99
|
+
commandline_options[:insert_title_heading] = false
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
parser.parse! argv
|
104
|
+
command = argv.shift
|
105
|
+
|
106
|
+
if argv.include?('-')
|
107
|
+
if argv.length > 1
|
108
|
+
$stderr.puts "Error: Cannot mix STDIN ('-') with other file arguments"
|
109
|
+
exit 1
|
110
|
+
end
|
111
|
+
|
112
|
+
commandline_options[:files] = []
|
113
|
+
commandline_options[:stdin_mode] = true
|
114
|
+
commandline_options[:stdin_content] = $stdin.read
|
115
|
+
|
116
|
+
# Because STDIN will be written to a temporary file, we don't want to preserve structure or autodrop;
|
117
|
+
# that filesystem should not be visible to the user.
|
118
|
+
commandline_options[:preserve_structure] = false
|
119
|
+
commandline_options[:autodrop] = true
|
120
|
+
|
121
|
+
else
|
122
|
+
commandline_options[:files] = argv
|
123
|
+
commandline_options[:stdin_mode] = false
|
124
|
+
end
|
125
|
+
|
126
|
+
if commandline_options[:style_mode] == :inline && commandline_options[:style_destination_directory]
|
127
|
+
raise ArgumentError, "--style-mode inline and --style-destination cannot be used together"
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
# Process files differently based on whether we're reading from STDIN
|
132
|
+
if commandline_options[:stdin_mode]
|
133
|
+
files = commandline_options[:files]
|
134
|
+
else
|
135
|
+
files = commandline_options[:files].map {|f| Pathname.new(f) }
|
136
|
+
end
|
137
|
+
|
138
|
+
commandline_config = Config.new(commandline_options)
|
139
|
+
config = Config.defaults.merge(Mint.configuration).merge(commandline_config)
|
140
|
+
|
141
|
+
[command, config, files, parser.help]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
3
|
+
require_relative "../config"
|
4
|
+
require_relative "../workspace"
|
5
|
+
|
6
|
+
module Mint
|
7
|
+
module Commandline
|
8
|
+
# For each file specified, publishes a new file based on configuration.
|
9
|
+
#
|
10
|
+
# @param [Array] source_files files a group of Pathname objects
|
11
|
+
# @param [Config, Hash] config a Config object or Hash with configuration options
|
12
|
+
def self.publish!(source_files, config: Config.new)
|
13
|
+
config = Config.ensure_config(config)
|
14
|
+
|
15
|
+
if source_files.empty?
|
16
|
+
raise ArgumentError, "No files specified. Use file paths or '-' to read from STDIN."
|
17
|
+
end
|
18
|
+
|
19
|
+
if config.stdin_mode
|
20
|
+
# source_files in this case is the actual content from STDIN, not a Pathname object
|
21
|
+
stdin_content = source_files.first
|
22
|
+
temp_file = Tempfile.new(['stdin', '.md'])
|
23
|
+
temp_file.write(stdin_content)
|
24
|
+
temp_file.close
|
25
|
+
|
26
|
+
# Convert the Tempfile path to a Pathname object
|
27
|
+
workspace = Workspace.new([Pathname.new(temp_file.path)], config)
|
28
|
+
destination_paths = workspace.publish!
|
29
|
+
output_file = destination_paths.first
|
30
|
+
if config.verbose
|
31
|
+
puts "Published: STDIN -> #{output_file}"
|
32
|
+
end
|
33
|
+
|
34
|
+
temp_file.unlink
|
35
|
+
else
|
36
|
+
workspace = Workspace.new(source_files, config)
|
37
|
+
destination_paths = workspace.publish!
|
38
|
+
if config.verbose
|
39
|
+
source_files.zip(destination_paths).each do |source_file, output_file|
|
40
|
+
puts "Published: #{source_file} -> #{output_file}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "../commandline/parse"
|
2
|
+
require_relative "../commandline/publish"
|
3
|
+
|
4
|
+
module Mint
|
5
|
+
module Commandline
|
6
|
+
def self.run!(argv)
|
7
|
+
command, config, files, help = Mint::Commandline.parse! argv
|
8
|
+
|
9
|
+
if config.help || command.nil?
|
10
|
+
puts help
|
11
|
+
exit 0
|
12
|
+
elsif command.to_sym == :publish
|
13
|
+
begin
|
14
|
+
Mint::Commandline.publish!(files, config: config)
|
15
|
+
rescue ArgumentError => e
|
16
|
+
$stderr.puts "Error: #{e.message}"
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
else
|
20
|
+
possible_binary = "mint-#{command}"
|
21
|
+
if File.executable? possible_binary
|
22
|
+
system "#{possible_binary} #{argv[1..-1].join ' '}"
|
23
|
+
else
|
24
|
+
$stderr.puts "Error: Unknown command '#{command}'"
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|