dsh-zju-lecture-note 2.2.3 → 2.2.4
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.
- package/CHANGELOG.md +41 -0
- package/README.md +8 -7
- package/docs/technical.md +26 -4
- package/mcp_server.py +1 -1
- package/package.json +1 -1
- package/skills/scholia-notes/SKILL.md +8 -1
- package/skills/scholia-notes/references/format-spec.md +57 -6
- package/skills/scholia-notes/references/prelude.typ +42 -0
- package/skills/scholia-notes/references/typography-spec.md +4 -4
- package/skills/scholia-notes.manifest.json +9 -9
- package/skills/zju-lecture-summarizer/SKILL.md +13 -1
- package/skills/zju-lecture-summarizer.manifest.json +4 -4
- package/zju_lecture/client.py +741 -741
- package/zju_lecture/handout.py +353 -57
- package/zju_lecture/handout_prelude.typ +35 -2
- package/zju_lecture/prelude.typ +42 -0
- package/zju_lecture/study_notes.py +296 -1
- package/zju_lecture/typst-packages/VENDORED.md +1 -1
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/LICENSE +20 -20
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/lib.typ +128 -128
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/typst.toml +15 -15
- package/zju_lecture/typst-packages/preview/scholia/0.1.0/src/lib.typ +2 -2
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/LICENSE +21 -21
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/func.typ +142 -142
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/id.typ +11 -11
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/pre-rendering.typ +50 -50
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/sections.typ +141 -141
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/shadows.typ +118 -118
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/showy.typ +267 -267
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/typst.toml +11 -11
|
@@ -1,268 +1,268 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ShowyBox - A package for Typst
|
|
3
|
-
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
-
*
|
|
5
|
-
* Main Contributors:
|
|
6
|
-
* - Jonas Neugebauer (<https://github.com/jneug>)
|
|
7
|
-
*
|
|
8
|
-
* showy.typ -- The package's main file containing the
|
|
9
|
-
* public and (more) useful functions
|
|
10
|
-
*
|
|
11
|
-
* This file is under the MIT license. For more
|
|
12
|
-
* information see LICENSE on the package's main folder.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/*
|
|
16
|
-
* Import functions
|
|
17
|
-
*/
|
|
18
|
-
#import "lib/func.typ": *
|
|
19
|
-
#import "lib/sections.typ": *
|
|
20
|
-
#import "lib/shadows.typ": *
|
|
21
|
-
#import "lib/id.typ": *
|
|
22
|
-
#import "lib/pre-rendering.typ": *
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
* Function: showybox()
|
|
26
|
-
*
|
|
27
|
-
* Description: Creates a showybox
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
#let showybox(
|
|
31
|
-
frame: (:),
|
|
32
|
-
title-style: (:),
|
|
33
|
-
boxed-style: (:),
|
|
34
|
-
body-style: (:),
|
|
35
|
-
footer-style: (:),
|
|
36
|
-
sep: (:),
|
|
37
|
-
shadow: none,
|
|
38
|
-
width: 100%,
|
|
39
|
-
breakable: false,
|
|
40
|
-
/* align: none, / collides with align-function */
|
|
41
|
-
/* spacing, above, and below are by default what's set for all `block`s */
|
|
42
|
-
title: "",
|
|
43
|
-
footer: "",
|
|
44
|
-
..body,
|
|
45
|
-
) = {
|
|
46
|
-
/*
|
|
47
|
-
* Complete and store all the dictionary-like-properties inside a
|
|
48
|
-
* single dictionary. This will improve readability and avoids to
|
|
49
|
-
* constantly have a default option while accessing
|
|
50
|
-
*/
|
|
51
|
-
let props = (
|
|
52
|
-
frame: (
|
|
53
|
-
title-color: frame.at("title-color", default: black),
|
|
54
|
-
body-color: frame.at("body-color", default: white),
|
|
55
|
-
border-color: frame.at("border-color", default: black),
|
|
56
|
-
footer-color: frame.at("footer-color", default: luma(220)),
|
|
57
|
-
inset: frame.at("inset", default: (x: 1em, y: .65em)),
|
|
58
|
-
radius: frame.at("radius", default: 5pt),
|
|
59
|
-
thickness: frame.at("thickness", default: 1pt),
|
|
60
|
-
dash: frame.at("dash", default: "solid"),
|
|
61
|
-
),
|
|
62
|
-
title-style: (
|
|
63
|
-
color: title-style.at("color", default: white),
|
|
64
|
-
weight: title-style.at("weight", default: "regular"),
|
|
65
|
-
align: title-style.at("align", default: start),
|
|
66
|
-
sep-thickness: title-style.at("sep-thickness", default: 1pt),
|
|
67
|
-
boxed-style: if title-style.at("boxed-style", default: none) != none and type(title-style.at("boxed-style", default: none)) == dictionary {
|
|
68
|
-
(
|
|
69
|
-
anchor: (
|
|
70
|
-
y: title-style.boxed-style.at("anchor", default: (:)).at("y", default: horizon),
|
|
71
|
-
x: title-style.boxed-style.at("anchor", default: (:)).at("x", default: start),
|
|
72
|
-
),
|
|
73
|
-
offset: (
|
|
74
|
-
x: title-style.boxed-style.at("offset", default: (:)).at("x", default: 0pt),
|
|
75
|
-
y: title-style.boxed-style.at("offset", default: (:)).at("y", default: 0pt),
|
|
76
|
-
),
|
|
77
|
-
radius: title-style.boxed-style.at("radius", default: 5pt),
|
|
78
|
-
)
|
|
79
|
-
} else {
|
|
80
|
-
none
|
|
81
|
-
},
|
|
82
|
-
),
|
|
83
|
-
body-style: (
|
|
84
|
-
color: body-style.at("color", default: black),
|
|
85
|
-
align: body-style.at("align", default: start),
|
|
86
|
-
),
|
|
87
|
-
footer-style: (
|
|
88
|
-
color: footer-style.at("color", default: luma(85)),
|
|
89
|
-
weight: footer-style.at("weight", default: "regular"),
|
|
90
|
-
align: footer-style.at("align", default: start),
|
|
91
|
-
sep-thickness: footer-style.at("sep-thickness", default: 1pt),
|
|
92
|
-
),
|
|
93
|
-
sep: (
|
|
94
|
-
thickness: sep.at("thickness", default: 1pt),
|
|
95
|
-
dash: sep.at("dash", default: "solid"),
|
|
96
|
-
gutter: sep.at("gutter", default: 0.65em),
|
|
97
|
-
),
|
|
98
|
-
shadow: if shadow != none {
|
|
99
|
-
if type(shadow.at("offset", default: 4pt)) != dictionary {
|
|
100
|
-
(offset: (
|
|
101
|
-
x: shadow.at("offset", default: 4pt),
|
|
102
|
-
y: shadow.at("offset", default: 4pt),
|
|
103
|
-
), color: shadow.at("color", default: luma(128)))
|
|
104
|
-
} else {
|
|
105
|
-
(offset: (
|
|
106
|
-
x: shadow.at("offset").at("x", default: 4pt),
|
|
107
|
-
y: shadow.at("offset").at("y", default: 4pt),
|
|
108
|
-
), color: shadow.at("color", default: luma(128)))
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
none
|
|
112
|
-
},
|
|
113
|
-
breakable: breakable,
|
|
114
|
-
width: width,
|
|
115
|
-
title: title,
|
|
116
|
-
)
|
|
117
|
-
// Add title, body and footer inset (if present)
|
|
118
|
-
for section-inset in ("title-inset", "body-inset", "footer-inset") {
|
|
119
|
-
let value = frame.at(section-inset, default: none)
|
|
120
|
-
if value != none {
|
|
121
|
-
props.frame.insert(section-inset, value)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
_showy-id.step()
|
|
126
|
-
context {
|
|
127
|
-
let id = str(_showy-id.get().first())
|
|
128
|
-
|
|
129
|
-
/*
|
|
130
|
-
* Update title height in state.
|
|
131
|
-
*
|
|
132
|
-
* NOTE: Although a `place` and `hide` are used in the pre-render
|
|
133
|
-
* function, for avoiding nesting components inside unaccesible
|
|
134
|
-
* containers, we must call this function inside another `place`.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
if title != "" and props.title-style.boxed-style != none {
|
|
138
|
-
place(top, showy-pre-render-title(props, id))
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/*
|
|
142
|
-
* Alignment wrapper
|
|
143
|
-
*/
|
|
144
|
-
let alignprops = (:)
|
|
145
|
-
for prop in ("spacing", "above", "below") {
|
|
146
|
-
if prop in body.named() {
|
|
147
|
-
alignprops.insert(prop, body.named().at(prop))
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
let alignwrap(content) = block(
|
|
151
|
-
..alignprops,
|
|
152
|
-
breakable: breakable,
|
|
153
|
-
width: 100%,
|
|
154
|
-
if "align" in body.named() and body.named().align != none {
|
|
155
|
-
align(body.named().align, content)
|
|
156
|
-
} else {
|
|
157
|
-
content
|
|
158
|
-
},
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
let showyblock = context {
|
|
162
|
-
let my-state = state("showybox-" + id, 0pt)
|
|
163
|
-
|
|
164
|
-
// /*
|
|
165
|
-
// * Decide wheter add a page break or not, based on the remaining
|
|
166
|
-
// * space in the page. For calculating it, we substract the page
|
|
167
|
-
// * margin to the page size. Later, we estimate a minimum size of
|
|
168
|
-
// * the showybox, adding the frame thickness, the frame inset,
|
|
169
|
-
// * and the size of 1 line of text.
|
|
170
|
-
// */
|
|
171
|
-
// let abs-margin = if page.margin == auto {
|
|
172
|
-
// let small-side = calc.min(page.height, page.width)
|
|
173
|
-
// (2.5/21) * small-side // According to docs, this is the 'auto' margin
|
|
174
|
-
// } else {
|
|
175
|
-
// margin.at("y", default: margin.at("top", default: margin.rest))
|
|
176
|
-
// }
|
|
177
|
-
|
|
178
|
-
// let remaining = 0pt
|
|
179
|
-
// let to-use = 0pt
|
|
180
|
-
// remaining = page.height - location.position(here()).y - abs-margin
|
|
181
|
-
// to-use += text.size.to-absolute()
|
|
182
|
-
|
|
183
|
-
// if type(props.frame.thickness) == dictionary {
|
|
184
|
-
// to-use += props.frame.thickness.at("y", default: props.frame.thickness.at("top", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
185
|
-
// to-use += props.frame.thickness.at("y", default: props.frame.thickness.at("bottom", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
186
|
-
// } else {
|
|
187
|
-
// to-use += 2*props.frame.thickness
|
|
188
|
-
// }
|
|
189
|
-
|
|
190
|
-
// if type(props.frame.inset) == dictionary {
|
|
191
|
-
// to-use += 4*props.frame.inset.at("y", default: props.frame.inset.at("top", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
192
|
-
// } else {
|
|
193
|
-
// to-use += 4*props.frame.inset.to-absolute()
|
|
194
|
-
// }
|
|
195
|
-
|
|
196
|
-
// // Since we cannot add a pagebreak directly, add the to-use space,
|
|
197
|
-
// // which would be greater than the remaining space.
|
|
198
|
-
// if remaining - to-use <= 0pt {
|
|
199
|
-
// v(to-use)
|
|
200
|
-
// }
|
|
201
|
-
|
|
202
|
-
if title != "" and props.title-style.boxed-style != none {
|
|
203
|
-
if props.title-style.boxed-style.anchor.y == bottom {
|
|
204
|
-
v(my-state.final())
|
|
205
|
-
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
206
|
-
v(my-state.final() / 2)
|
|
207
|
-
} // Otherwise don't add extra space
|
|
208
|
-
|
|
209
|
-
// Add the boxed-title shadow before rendering the body
|
|
210
|
-
if props.shadow != none {
|
|
211
|
-
showy-boxed-title-shadow(props, id)
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
block(
|
|
216
|
-
width: if props.shadow == none {
|
|
217
|
-
width
|
|
218
|
-
} else {
|
|
219
|
-
100%
|
|
220
|
-
},
|
|
221
|
-
fill: props.frame.body-color,
|
|
222
|
-
radius: props.frame.radius,
|
|
223
|
-
inset: 0pt,
|
|
224
|
-
spacing: 0pt,
|
|
225
|
-
breakable: breakable,
|
|
226
|
-
stroke: showy-stroke(props.frame),
|
|
227
|
-
)[
|
|
228
|
-
/*
|
|
229
|
-
* Title of the showybox
|
|
230
|
-
*/
|
|
231
|
-
#if title != "" and props.title-style.boxed-style == none {
|
|
232
|
-
showy-title(props)
|
|
233
|
-
} else if title != "" and props.title-style.boxed-style != none {
|
|
234
|
-
if props.title-style.boxed-style.anchor.y == top {
|
|
235
|
-
v(my-state.final())
|
|
236
|
-
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
237
|
-
v(my-state.final() / 2)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
place(
|
|
241
|
-
top + props.title-style.boxed-style.anchor.x,
|
|
242
|
-
dx: props.title-style.boxed-style.offset.x,
|
|
243
|
-
dy: props.title-style.boxed-style.offset.y + if props.title-style.boxed-style.anchor.y == bottom {
|
|
244
|
-
-my-state.final()
|
|
245
|
-
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
246
|
-
-my-state.final() / 2
|
|
247
|
-
},
|
|
248
|
-
block(spacing: 0pt, inset: (x: 1em), showy-title(props)),
|
|
249
|
-
)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/*
|
|
253
|
-
* Body of the showybox
|
|
254
|
-
*/
|
|
255
|
-
#showy-body(props, ..body)
|
|
256
|
-
|
|
257
|
-
/*
|
|
258
|
-
* Footer of the showybox
|
|
259
|
-
*/
|
|
260
|
-
#if footer != "" {
|
|
261
|
-
showy-footer(props, footer)
|
|
262
|
-
}
|
|
263
|
-
]
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
alignwrap(showy-shadow(props, showyblock, id))
|
|
267
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* ShowyBox - A package for Typst
|
|
3
|
+
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
+
*
|
|
5
|
+
* Main Contributors:
|
|
6
|
+
* - Jonas Neugebauer (<https://github.com/jneug>)
|
|
7
|
+
*
|
|
8
|
+
* showy.typ -- The package's main file containing the
|
|
9
|
+
* public and (more) useful functions
|
|
10
|
+
*
|
|
11
|
+
* This file is under the MIT license. For more
|
|
12
|
+
* information see LICENSE on the package's main folder.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Import functions
|
|
17
|
+
*/
|
|
18
|
+
#import "lib/func.typ": *
|
|
19
|
+
#import "lib/sections.typ": *
|
|
20
|
+
#import "lib/shadows.typ": *
|
|
21
|
+
#import "lib/id.typ": *
|
|
22
|
+
#import "lib/pre-rendering.typ": *
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Function: showybox()
|
|
26
|
+
*
|
|
27
|
+
* Description: Creates a showybox
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
#let showybox(
|
|
31
|
+
frame: (:),
|
|
32
|
+
title-style: (:),
|
|
33
|
+
boxed-style: (:),
|
|
34
|
+
body-style: (:),
|
|
35
|
+
footer-style: (:),
|
|
36
|
+
sep: (:),
|
|
37
|
+
shadow: none,
|
|
38
|
+
width: 100%,
|
|
39
|
+
breakable: false,
|
|
40
|
+
/* align: none, / collides with align-function */
|
|
41
|
+
/* spacing, above, and below are by default what's set for all `block`s */
|
|
42
|
+
title: "",
|
|
43
|
+
footer: "",
|
|
44
|
+
..body,
|
|
45
|
+
) = {
|
|
46
|
+
/*
|
|
47
|
+
* Complete and store all the dictionary-like-properties inside a
|
|
48
|
+
* single dictionary. This will improve readability and avoids to
|
|
49
|
+
* constantly have a default option while accessing
|
|
50
|
+
*/
|
|
51
|
+
let props = (
|
|
52
|
+
frame: (
|
|
53
|
+
title-color: frame.at("title-color", default: black),
|
|
54
|
+
body-color: frame.at("body-color", default: white),
|
|
55
|
+
border-color: frame.at("border-color", default: black),
|
|
56
|
+
footer-color: frame.at("footer-color", default: luma(220)),
|
|
57
|
+
inset: frame.at("inset", default: (x: 1em, y: .65em)),
|
|
58
|
+
radius: frame.at("radius", default: 5pt),
|
|
59
|
+
thickness: frame.at("thickness", default: 1pt),
|
|
60
|
+
dash: frame.at("dash", default: "solid"),
|
|
61
|
+
),
|
|
62
|
+
title-style: (
|
|
63
|
+
color: title-style.at("color", default: white),
|
|
64
|
+
weight: title-style.at("weight", default: "regular"),
|
|
65
|
+
align: title-style.at("align", default: start),
|
|
66
|
+
sep-thickness: title-style.at("sep-thickness", default: 1pt),
|
|
67
|
+
boxed-style: if title-style.at("boxed-style", default: none) != none and type(title-style.at("boxed-style", default: none)) == dictionary {
|
|
68
|
+
(
|
|
69
|
+
anchor: (
|
|
70
|
+
y: title-style.boxed-style.at("anchor", default: (:)).at("y", default: horizon),
|
|
71
|
+
x: title-style.boxed-style.at("anchor", default: (:)).at("x", default: start),
|
|
72
|
+
),
|
|
73
|
+
offset: (
|
|
74
|
+
x: title-style.boxed-style.at("offset", default: (:)).at("x", default: 0pt),
|
|
75
|
+
y: title-style.boxed-style.at("offset", default: (:)).at("y", default: 0pt),
|
|
76
|
+
),
|
|
77
|
+
radius: title-style.boxed-style.at("radius", default: 5pt),
|
|
78
|
+
)
|
|
79
|
+
} else {
|
|
80
|
+
none
|
|
81
|
+
},
|
|
82
|
+
),
|
|
83
|
+
body-style: (
|
|
84
|
+
color: body-style.at("color", default: black),
|
|
85
|
+
align: body-style.at("align", default: start),
|
|
86
|
+
),
|
|
87
|
+
footer-style: (
|
|
88
|
+
color: footer-style.at("color", default: luma(85)),
|
|
89
|
+
weight: footer-style.at("weight", default: "regular"),
|
|
90
|
+
align: footer-style.at("align", default: start),
|
|
91
|
+
sep-thickness: footer-style.at("sep-thickness", default: 1pt),
|
|
92
|
+
),
|
|
93
|
+
sep: (
|
|
94
|
+
thickness: sep.at("thickness", default: 1pt),
|
|
95
|
+
dash: sep.at("dash", default: "solid"),
|
|
96
|
+
gutter: sep.at("gutter", default: 0.65em),
|
|
97
|
+
),
|
|
98
|
+
shadow: if shadow != none {
|
|
99
|
+
if type(shadow.at("offset", default: 4pt)) != dictionary {
|
|
100
|
+
(offset: (
|
|
101
|
+
x: shadow.at("offset", default: 4pt),
|
|
102
|
+
y: shadow.at("offset", default: 4pt),
|
|
103
|
+
), color: shadow.at("color", default: luma(128)))
|
|
104
|
+
} else {
|
|
105
|
+
(offset: (
|
|
106
|
+
x: shadow.at("offset").at("x", default: 4pt),
|
|
107
|
+
y: shadow.at("offset").at("y", default: 4pt),
|
|
108
|
+
), color: shadow.at("color", default: luma(128)))
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
none
|
|
112
|
+
},
|
|
113
|
+
breakable: breakable,
|
|
114
|
+
width: width,
|
|
115
|
+
title: title,
|
|
116
|
+
)
|
|
117
|
+
// Add title, body and footer inset (if present)
|
|
118
|
+
for section-inset in ("title-inset", "body-inset", "footer-inset") {
|
|
119
|
+
let value = frame.at(section-inset, default: none)
|
|
120
|
+
if value != none {
|
|
121
|
+
props.frame.insert(section-inset, value)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_showy-id.step()
|
|
126
|
+
context {
|
|
127
|
+
let id = str(_showy-id.get().first())
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* Update title height in state.
|
|
131
|
+
*
|
|
132
|
+
* NOTE: Although a `place` and `hide` are used in the pre-render
|
|
133
|
+
* function, for avoiding nesting components inside unaccesible
|
|
134
|
+
* containers, we must call this function inside another `place`.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
if title != "" and props.title-style.boxed-style != none {
|
|
138
|
+
place(top, showy-pre-render-title(props, id))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/*
|
|
142
|
+
* Alignment wrapper
|
|
143
|
+
*/
|
|
144
|
+
let alignprops = (:)
|
|
145
|
+
for prop in ("spacing", "above", "below") {
|
|
146
|
+
if prop in body.named() {
|
|
147
|
+
alignprops.insert(prop, body.named().at(prop))
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
let alignwrap(content) = block(
|
|
151
|
+
..alignprops,
|
|
152
|
+
breakable: breakable,
|
|
153
|
+
width: 100%,
|
|
154
|
+
if "align" in body.named() and body.named().align != none {
|
|
155
|
+
align(body.named().align, content)
|
|
156
|
+
} else {
|
|
157
|
+
content
|
|
158
|
+
},
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
let showyblock = context {
|
|
162
|
+
let my-state = state("showybox-" + id, 0pt)
|
|
163
|
+
|
|
164
|
+
// /*
|
|
165
|
+
// * Decide wheter add a page break or not, based on the remaining
|
|
166
|
+
// * space in the page. For calculating it, we substract the page
|
|
167
|
+
// * margin to the page size. Later, we estimate a minimum size of
|
|
168
|
+
// * the showybox, adding the frame thickness, the frame inset,
|
|
169
|
+
// * and the size of 1 line of text.
|
|
170
|
+
// */
|
|
171
|
+
// let abs-margin = if page.margin == auto {
|
|
172
|
+
// let small-side = calc.min(page.height, page.width)
|
|
173
|
+
// (2.5/21) * small-side // According to docs, this is the 'auto' margin
|
|
174
|
+
// } else {
|
|
175
|
+
// margin.at("y", default: margin.at("top", default: margin.rest))
|
|
176
|
+
// }
|
|
177
|
+
|
|
178
|
+
// let remaining = 0pt
|
|
179
|
+
// let to-use = 0pt
|
|
180
|
+
// remaining = page.height - location.position(here()).y - abs-margin
|
|
181
|
+
// to-use += text.size.to-absolute()
|
|
182
|
+
|
|
183
|
+
// if type(props.frame.thickness) == dictionary {
|
|
184
|
+
// to-use += props.frame.thickness.at("y", default: props.frame.thickness.at("top", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
185
|
+
// to-use += props.frame.thickness.at("y", default: props.frame.thickness.at("bottom", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
186
|
+
// } else {
|
|
187
|
+
// to-use += 2*props.frame.thickness
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
// if type(props.frame.inset) == dictionary {
|
|
191
|
+
// to-use += 4*props.frame.inset.at("y", default: props.frame.inset.at("top", default: props.frame.inset.at("rest", default: .65em))).to-absolute()
|
|
192
|
+
// } else {
|
|
193
|
+
// to-use += 4*props.frame.inset.to-absolute()
|
|
194
|
+
// }
|
|
195
|
+
|
|
196
|
+
// // Since we cannot add a pagebreak directly, add the to-use space,
|
|
197
|
+
// // which would be greater than the remaining space.
|
|
198
|
+
// if remaining - to-use <= 0pt {
|
|
199
|
+
// v(to-use)
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
if title != "" and props.title-style.boxed-style != none {
|
|
203
|
+
if props.title-style.boxed-style.anchor.y == bottom {
|
|
204
|
+
v(my-state.final())
|
|
205
|
+
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
206
|
+
v(my-state.final() / 2)
|
|
207
|
+
} // Otherwise don't add extra space
|
|
208
|
+
|
|
209
|
+
// Add the boxed-title shadow before rendering the body
|
|
210
|
+
if props.shadow != none {
|
|
211
|
+
showy-boxed-title-shadow(props, id)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
block(
|
|
216
|
+
width: if props.shadow == none {
|
|
217
|
+
width
|
|
218
|
+
} else {
|
|
219
|
+
100%
|
|
220
|
+
},
|
|
221
|
+
fill: props.frame.body-color,
|
|
222
|
+
radius: props.frame.radius,
|
|
223
|
+
inset: 0pt,
|
|
224
|
+
spacing: 0pt,
|
|
225
|
+
breakable: breakable,
|
|
226
|
+
stroke: showy-stroke(props.frame),
|
|
227
|
+
)[
|
|
228
|
+
/*
|
|
229
|
+
* Title of the showybox
|
|
230
|
+
*/
|
|
231
|
+
#if title != "" and props.title-style.boxed-style == none {
|
|
232
|
+
showy-title(props)
|
|
233
|
+
} else if title != "" and props.title-style.boxed-style != none {
|
|
234
|
+
if props.title-style.boxed-style.anchor.y == top {
|
|
235
|
+
v(my-state.final())
|
|
236
|
+
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
237
|
+
v(my-state.final() / 2)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
place(
|
|
241
|
+
top + props.title-style.boxed-style.anchor.x,
|
|
242
|
+
dx: props.title-style.boxed-style.offset.x,
|
|
243
|
+
dy: props.title-style.boxed-style.offset.y + if props.title-style.boxed-style.anchor.y == bottom {
|
|
244
|
+
-my-state.final()
|
|
245
|
+
} else if props.title-style.boxed-style.anchor.y == horizon {
|
|
246
|
+
-my-state.final() / 2
|
|
247
|
+
},
|
|
248
|
+
block(spacing: 0pt, inset: (x: 1em), showy-title(props)),
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/*
|
|
253
|
+
* Body of the showybox
|
|
254
|
+
*/
|
|
255
|
+
#showy-body(props, ..body)
|
|
256
|
+
|
|
257
|
+
/*
|
|
258
|
+
* Footer of the showybox
|
|
259
|
+
*/
|
|
260
|
+
#if footer != "" {
|
|
261
|
+
showy-footer(props, footer)
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
alignwrap(showy-shadow(props, showyblock, id))
|
|
267
|
+
}
|
|
268
268
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "showybox"
|
|
3
|
-
version = "2.0.4"
|
|
4
|
-
entrypoint = "showy.typ"
|
|
5
|
-
authors = ["Pablo González Calderón", "Showybox Contributors"]
|
|
6
|
-
license = "MIT"
|
|
7
|
-
categories = ["components"]
|
|
8
|
-
keywords = ["boxes", "colorful"]
|
|
9
|
-
compiler = "0.12.0"
|
|
10
|
-
description = "Colorful and customizable boxes for Typst"
|
|
11
|
-
repository = "https://github.com/Pablo-Gonzalez-Calderon/showybox-package"
|
|
1
|
+
[package]
|
|
2
|
+
name = "showybox"
|
|
3
|
+
version = "2.0.4"
|
|
4
|
+
entrypoint = "showy.typ"
|
|
5
|
+
authors = ["Pablo González Calderón", "Showybox Contributors"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
categories = ["components"]
|
|
8
|
+
keywords = ["boxes", "colorful"]
|
|
9
|
+
compiler = "0.12.0"
|
|
10
|
+
description = "Colorful and customizable boxes for Typst"
|
|
11
|
+
repository = "https://github.com/Pablo-Gonzalez-Calderon/showybox-package"
|
|
12
12
|
exclude = ["assets", "Showybox's Manual.pdf", "examples", "manual"]
|