Skip to content

Commit 48ca9c8

Browse files
committed
fix: adapt cli and add matching config struct
1 parent b85a859 commit 48ca9c8

File tree

2 files changed

+106
-71
lines changed

2 files changed

+106
-71
lines changed

Diff for: src/cli.yml

+33-71
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ args:
7373
- render-block
7474
- math-block
7575
- figure-insert
76-
- verbatim-block-file-insert
77-
- rendered-block-file-insert
76+
- verbatim-block-insert
77+
- render-block-insert
7878
- text-block
7979
- quotation-block
8080
- line-block
8181
- definition-block
82-
- explicit-column-block
83-
- implicit-column-block
82+
- explicit-column
83+
- implicit-column
8484
- field-block
8585
- output-block
8686
- media-block-insert
@@ -108,21 +108,39 @@ args:
108108
- render-block
109109
- math-block
110110
- figure-insert
111-
- verbatim-block-file-insert
112-
- rendered-block-file-insert
111+
- verbatim-block-insert
112+
- render-block-insert
113113
- text-block
114114
- quotation-block
115115
- line-block
116116
- definition-block
117-
- explicit-column-block
118-
- implicit-column-block
117+
- explicit-column
118+
- implicit-column
119119
- field-block
120120
- output-block
121121
- media-block-insert
122122
- form-block
123123
- macros
124124
- variables
125125

126+
- fonts:
127+
display_order: 10
128+
long: fonts
129+
alias: ttf
130+
alias: woff
131+
help: Set ttf or woff fonts to be able to use them for rendering
132+
takes_value: true
133+
use_delimiter: true
134+
135+
- relative_insert_prefix:
136+
display_order: 20
137+
long: relative-insert-prefix
138+
alias: insert-prefix
139+
help: |
140+
This prefix will be set before inserts in the rendered document to inserts that use relative paths.
141+
Note: During rendering, the original relative path is taken.
142+
takes_value: true
143+
126144
## Reference options
127145

128146
- citation_style:
@@ -146,74 +164,25 @@ args:
146164

147165
## HTML options
148166

149-
- html_root_path:
167+
- html_template:
150168
display_order: 40
151-
long: html-root
152-
help: Set the root path that will be set before relative file and image inserts.
169+
long: html-template
170+
help: |
171+
Set a template html file with `{{ head }}` set inside the `head` element and `{{ body }}` set inside the body element.
172+
Styling, fonts and scripts will be inserted at `{{ head }}` and the rendered Unimarkup content is placed inside `{{ body }}`.
173+
Optionally, `{{ toc }}` can be set to get the table of contents (Note: This will not remove a rendered table of contents inside the rendered Unimarkup content if present).
153174
takes_value: true
154175

155176
- html_mathmode:
156177
display_order: 41
157178
long: html-mathmode
158-
help: Set the mathmode to be used for rendered html documents
179+
help: Set the mathmode of MathJax to be used for rendered html documents.
159180
takes_value: true
160181
possible_values:
161182
- svg
162183
- embed
163184
- cdn
164185

165-
## PDF options
166-
167-
- pdf_layout:
168-
display_order: 50
169-
long: pdf-layout
170-
help: Set the pdf layout of the rendered document. The custom format must be set with the options `--pdf-custom-height` and `--pdf-custom-width`.
171-
takes_value: true
172-
possible_values:
173-
- A5
174-
- A4
175-
- A3
176-
- A2
177-
- A1
178-
- A0
179-
- Custom
180-
181-
- pdf_orientation:
182-
display_order: 51
183-
long: pdf-orientation
184-
help: Set the pdf orientation of the rendered document.
185-
takes_value: true
186-
possible_values:
187-
- vertical
188-
- horizontal
189-
requires:
190-
- pdf_layout
191-
192-
- ttf:
193-
display_order: 52
194-
long: true-type-font
195-
alias: ttf
196-
help: Set true type fonts to be able to use them for rendering
197-
takes_value: true
198-
use_delimiter: true
199-
200-
- pdf_custom_height:
201-
display_order: 53
202-
long: pdf-custom-height
203-
help: Set a custom height [in mm] for the rendered pdf document.
204-
takes_value: true
205-
requires:
206-
- pdf_layout
207-
208-
- pdf_custom_width:
209-
display_order: 54
210-
long: pdf-custom-width
211-
help: Set a custom width [in mm] for the rendered pdf document.
212-
takes_value: true
213-
requires:
214-
- pdf_layout
215-
216-
217186
# ----------- Flags ---------------------------------------------------------------------------
218187
## General flags
219188

@@ -252,13 +221,6 @@ args:
252221
long: html-embed-svg
253222
help: Set if svgs should be embedded into html instead of inserted as regular images.
254223

255-
- html_standalone:
256-
display_order: 41
257-
long: html-standalone
258-
help: |
259-
Set to get a HTML5 compliant rendered html document with head and body elements.
260-
Otherwise, only elements of the Unimarkup document are rendered for the html document.
261-
262224
# --------- Positionals -------------------------------------------------------------------------
263225

264226
- um_file:

Diff for: src/config.rs

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
pub struct Config {
3+
um_file: String,
4+
out_file: String,
5+
insert_paths: Vec<String>,
6+
dot_unimarkup: String,
7+
theme: String,
8+
flags: Vec<String>,
9+
enable_elements: Vec<UmBlockElements>,
10+
disable_elements: Vec<UmBlockElements>,
11+
citation_style: String,
12+
references: String,
13+
fonts: Vec<String>,
14+
overwrite_existing: bool,
15+
clean: bool,
16+
rebuild: bool,
17+
replace_preamble: bool,
18+
outputs: Vec<OutputConfig>,
19+
}
20+
21+
pub struct OutputConfig {
22+
out_file: String,
23+
out_type: OutputFormat,
24+
theme: String,
25+
flags: Vec<String>,
26+
relative_insert_prefix: String,
27+
html_template: String,
28+
html_mathmode: HtmlMathmode,
29+
html_embed_svg: bool,
30+
}
31+
32+
pub enum OutputFormat {
33+
PDF,
34+
HTML,
35+
REVEAL_JS,
36+
INTERMEDIATE,
37+
}
38+
39+
pub enum HtmlMathmode {
40+
SVG,
41+
EMBED,
42+
CDN,
43+
}
44+
45+
pub enum UmBlockElements {
46+
PARAGRAPH,
47+
HEADING,
48+
BULLET_LIST,
49+
NUMBERED_LIST,
50+
TASK_LIST,
51+
DEFINITION_LIST,
52+
TABLE,
53+
VERBATIM_BLOCK,
54+
RENDER_BLOCK,
55+
MATH_BLOCK,
56+
FIGURE_INSERT,
57+
VERBATIM_BLOCK_INSERT,
58+
RENDER_BLOCK_INSERT,
59+
TEXT_BLOCK,
60+
QUOTATION_BLOCK,
61+
LINE_BLOCK,
62+
DEFINITION_BLOCK,
63+
EXPLICIT_COLUMN,
64+
IMPLICIT_COLUMN,
65+
FIELD_BLOCK,
66+
OUTPUT_BLOCK,
67+
MEDIA_BLOCK_INSERT,
68+
FORM_BLOCK,
69+
MACROS,
70+
VARIABLES,
71+
}
72+
73+

0 commit comments

Comments
 (0)