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,15 +1,15 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "noteworthy"
|
|
3
|
-
version = "0.4.0"
|
|
4
|
-
entrypoint = "lib.typ"
|
|
5
|
-
authors = ["Tarun Kumar Jana <https://tarunjana.in>"]
|
|
6
|
-
license = "MIT"
|
|
7
|
-
description = "Mathematics notes for modern classrooms."
|
|
8
|
-
repository = "https://github.com/tarunjana/noteworthy"
|
|
9
|
-
keywords = ["typst-template", "class-notes", "mathematics"]
|
|
10
|
-
categories = ["report"]
|
|
11
|
-
|
|
12
|
-
[template]
|
|
13
|
-
path = "template"
|
|
14
|
-
entrypoint = "main.typ"
|
|
15
|
-
thumbnail = "thumbnail.png"
|
|
1
|
+
[package]
|
|
2
|
+
name = "noteworthy"
|
|
3
|
+
version = "0.4.0"
|
|
4
|
+
entrypoint = "lib.typ"
|
|
5
|
+
authors = ["Tarun Kumar Jana <https://tarunjana.in>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
description = "Mathematics notes for modern classrooms."
|
|
8
|
+
repository = "https://github.com/tarunjana/noteworthy"
|
|
9
|
+
keywords = ["typst-template", "class-notes", "mathematics"]
|
|
10
|
+
categories = ["report"]
|
|
11
|
+
|
|
12
|
+
[template]
|
|
13
|
+
path = "template"
|
|
14
|
+
entrypoint = "main.typ"
|
|
15
|
+
thumbnail = "thumbnail.png"
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
// section: number + title over a rule; reset the per-section knot counter
|
|
162
162
|
show heading.where(level: 1): it => {
|
|
163
163
|
counter(figure.where(kind: "frame")).update(0)
|
|
164
|
-
block(above:
|
|
164
|
+
block(above: 24pt, below: 12pt, width: 100%)[
|
|
165
165
|
#text(font: hfont, weight: "bold", size: 15pt, fill: p.muted)[#counter(heading).display()]
|
|
166
166
|
#h(0.7em)
|
|
167
167
|
#text(font: hfont, weight: "bold", size: 15pt, fill: p.thm)[#it.body]
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
#line(length: 100%, stroke: 1.1pt + p.rule)
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
|
-
show heading.where(level: 2): it => block(above:
|
|
172
|
+
show heading.where(level: 2): it => block(above: 22pt, below: 0.85em)[
|
|
173
173
|
#text(font: hfont, weight: "bold", size: 12.5pt, fill: p.def)[#counter(heading).display() #it.body]
|
|
174
174
|
]
|
|
175
175
|
show heading.where(level: 3): it => block(above: 9pt, below: 0.65em)[
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023-2024 Pablo González Calderón and Showybox Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2024 Pablo González Calderón and Showybox Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ShowyBox - A package for Typst
|
|
3
|
-
* Pablo González Calderón and Showybox Contributors (c) 2023
|
|
4
|
-
*
|
|
5
|
-
* lib/func.typ -- The package's file containing all the
|
|
6
|
-
* internal functions used by showybox()
|
|
7
|
-
*
|
|
8
|
-
* This file is under the MIT license. For more
|
|
9
|
-
* information see LICENSE on the package's main folder.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Function: showy-value-in-direction()
|
|
14
|
-
*
|
|
15
|
-
* Description: Helper function to get a value
|
|
16
|
-
* in a specific direction inside a dictionary or value
|
|
17
|
-
*
|
|
18
|
-
* Parameters:
|
|
19
|
-
* + direction: Direction as an alignement or string
|
|
20
|
-
* + value: Dictionary or value to search in
|
|
21
|
-
* + default: Default value if nothing is found
|
|
22
|
-
*/
|
|
23
|
-
#let showy-value-in-direction(direction, value, default) = {
|
|
24
|
-
if type(direction) != str {
|
|
25
|
-
direction = repr(direction)
|
|
26
|
-
}
|
|
27
|
-
if type(value) == dictionary {
|
|
28
|
-
if direction in value {
|
|
29
|
-
value.at(direction)
|
|
30
|
-
} else if direction in ("left", "right") and "x" in value {
|
|
31
|
-
value.x
|
|
32
|
-
} else if direction in ("top", "bottom") and "y" in value {
|
|
33
|
-
value.y
|
|
34
|
-
} else if direction in ("top-left", "top-right") and "top" in value {
|
|
35
|
-
value.top
|
|
36
|
-
} else if direction in ("bottom-left", "bottom-right") and "bottom" in value {
|
|
37
|
-
value.bottom
|
|
38
|
-
} else if "rest" in value {
|
|
39
|
-
value.rest
|
|
40
|
-
} else {
|
|
41
|
-
default
|
|
42
|
-
}
|
|
43
|
-
} else if value == none {
|
|
44
|
-
default
|
|
45
|
-
} else {
|
|
46
|
-
value
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
* Function: showy-section-inset()
|
|
52
|
-
*
|
|
53
|
-
* Description: Gets the inset value for the given
|
|
54
|
-
* section ("title", "body", "footer"), checking if
|
|
55
|
-
* it's declared in `title-inset`, `body-inset` or
|
|
56
|
-
* `footer-inset` instead of `inset`
|
|
57
|
-
*
|
|
58
|
-
* Parameters:
|
|
59
|
-
* + section: Section to retrieve the inset ("title", "body" or "footer")
|
|
60
|
-
* + frame: The dictionary with frame settings
|
|
61
|
-
*/
|
|
62
|
-
#let showy-section-inset(section, frame) = {
|
|
63
|
-
return frame.at(
|
|
64
|
-
section + "-inset",
|
|
65
|
-
default: frame.inset
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
* Function: showy-line()
|
|
71
|
-
*
|
|
72
|
-
* Description: Creates a modified `#line()` function
|
|
73
|
-
* to draw a separator line with start and end points
|
|
74
|
-
* adjusted to insets.
|
|
75
|
-
*
|
|
76
|
-
* Parameters:
|
|
77
|
-
* + frame: The dictionary with frame settings
|
|
78
|
-
*/
|
|
79
|
-
#let showy-line(frame) = {
|
|
80
|
-
let inset = showy-section-inset("body", frame)
|
|
81
|
-
let inset = (
|
|
82
|
-
left: showy-value-in-direction(left, inset, 0pt),
|
|
83
|
-
right: showy-value-in-direction(right, inset, 0pt)
|
|
84
|
-
)
|
|
85
|
-
let (start, end) = (0%, 0%)
|
|
86
|
-
|
|
87
|
-
// For relative insets the original width needs to be calculated
|
|
88
|
-
if type(inset.left) == ratio and type(inset.right) == ratio {
|
|
89
|
-
let full = 100% / (1 - float(inset.right) - float(inset.left))
|
|
90
|
-
start = -inset.left * full
|
|
91
|
-
end = full + start
|
|
92
|
-
} else if type(inset.left) == ratio {
|
|
93
|
-
let full = (100% + inset.right) / (1 - float(inset.left))
|
|
94
|
-
(start, end) = (-inset.left * full, 100% + inset.right)
|
|
95
|
-
} else if type(inset.right) == ratio {
|
|
96
|
-
let full = (100% + inset.left) / (1 - float(inset.right))
|
|
97
|
-
(start, end) = (-inset.left, full - inset.left)
|
|
98
|
-
} else {
|
|
99
|
-
(start, end) = (-inset.left, 100% + inset.right)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
line.with(
|
|
103
|
-
start: (start, 0%),
|
|
104
|
-
end: (end, 0%)
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
/*
|
|
108
|
-
* Function: showy-stroke()
|
|
109
|
-
*
|
|
110
|
-
* Description: Creates a stroke or set of strokes
|
|
111
|
-
* to use as borders.
|
|
112
|
-
*
|
|
113
|
-
* Parameters:
|
|
114
|
-
* + frame: The dictionary with frame settings
|
|
115
|
-
*/
|
|
116
|
-
#let showy-stroke(frame, ..overrides) = {
|
|
117
|
-
let (paint, dash, width) = (
|
|
118
|
-
frame.border-color,
|
|
119
|
-
frame.dash,
|
|
120
|
-
frame.thickness
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
let strokes = (:)
|
|
124
|
-
if type(width) != dictionary { // Set all borders at once
|
|
125
|
-
for side in ("top", "bottom", "left", "right") {
|
|
126
|
-
strokes.insert(side, (paint: paint, dash: dash, thickness: width))
|
|
127
|
-
}
|
|
128
|
-
} else { // Set each border individually
|
|
129
|
-
for pair in width {
|
|
130
|
-
strokes.insert(
|
|
131
|
-
pair.first(), // key
|
|
132
|
-
(paint: paint, dash: dash, thickness: pair.last())
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
for pair in overrides.named() {
|
|
137
|
-
strokes.insert(
|
|
138
|
-
pair.first(),
|
|
139
|
-
(paint: paint, dash: dash, thickness: pair.last())
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
return strokes
|
|
1
|
+
/*
|
|
2
|
+
* ShowyBox - A package for Typst
|
|
3
|
+
* Pablo González Calderón and Showybox Contributors (c) 2023
|
|
4
|
+
*
|
|
5
|
+
* lib/func.typ -- The package's file containing all the
|
|
6
|
+
* internal functions used by showybox()
|
|
7
|
+
*
|
|
8
|
+
* This file is under the MIT license. For more
|
|
9
|
+
* information see LICENSE on the package's main folder.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Function: showy-value-in-direction()
|
|
14
|
+
*
|
|
15
|
+
* Description: Helper function to get a value
|
|
16
|
+
* in a specific direction inside a dictionary or value
|
|
17
|
+
*
|
|
18
|
+
* Parameters:
|
|
19
|
+
* + direction: Direction as an alignement or string
|
|
20
|
+
* + value: Dictionary or value to search in
|
|
21
|
+
* + default: Default value if nothing is found
|
|
22
|
+
*/
|
|
23
|
+
#let showy-value-in-direction(direction, value, default) = {
|
|
24
|
+
if type(direction) != str {
|
|
25
|
+
direction = repr(direction)
|
|
26
|
+
}
|
|
27
|
+
if type(value) == dictionary {
|
|
28
|
+
if direction in value {
|
|
29
|
+
value.at(direction)
|
|
30
|
+
} else if direction in ("left", "right") and "x" in value {
|
|
31
|
+
value.x
|
|
32
|
+
} else if direction in ("top", "bottom") and "y" in value {
|
|
33
|
+
value.y
|
|
34
|
+
} else if direction in ("top-left", "top-right") and "top" in value {
|
|
35
|
+
value.top
|
|
36
|
+
} else if direction in ("bottom-left", "bottom-right") and "bottom" in value {
|
|
37
|
+
value.bottom
|
|
38
|
+
} else if "rest" in value {
|
|
39
|
+
value.rest
|
|
40
|
+
} else {
|
|
41
|
+
default
|
|
42
|
+
}
|
|
43
|
+
} else if value == none {
|
|
44
|
+
default
|
|
45
|
+
} else {
|
|
46
|
+
value
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Function: showy-section-inset()
|
|
52
|
+
*
|
|
53
|
+
* Description: Gets the inset value for the given
|
|
54
|
+
* section ("title", "body", "footer"), checking if
|
|
55
|
+
* it's declared in `title-inset`, `body-inset` or
|
|
56
|
+
* `footer-inset` instead of `inset`
|
|
57
|
+
*
|
|
58
|
+
* Parameters:
|
|
59
|
+
* + section: Section to retrieve the inset ("title", "body" or "footer")
|
|
60
|
+
* + frame: The dictionary with frame settings
|
|
61
|
+
*/
|
|
62
|
+
#let showy-section-inset(section, frame) = {
|
|
63
|
+
return frame.at(
|
|
64
|
+
section + "-inset",
|
|
65
|
+
default: frame.inset
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Function: showy-line()
|
|
71
|
+
*
|
|
72
|
+
* Description: Creates a modified `#line()` function
|
|
73
|
+
* to draw a separator line with start and end points
|
|
74
|
+
* adjusted to insets.
|
|
75
|
+
*
|
|
76
|
+
* Parameters:
|
|
77
|
+
* + frame: The dictionary with frame settings
|
|
78
|
+
*/
|
|
79
|
+
#let showy-line(frame) = {
|
|
80
|
+
let inset = showy-section-inset("body", frame)
|
|
81
|
+
let inset = (
|
|
82
|
+
left: showy-value-in-direction(left, inset, 0pt),
|
|
83
|
+
right: showy-value-in-direction(right, inset, 0pt)
|
|
84
|
+
)
|
|
85
|
+
let (start, end) = (0%, 0%)
|
|
86
|
+
|
|
87
|
+
// For relative insets the original width needs to be calculated
|
|
88
|
+
if type(inset.left) == ratio and type(inset.right) == ratio {
|
|
89
|
+
let full = 100% / (1 - float(inset.right) - float(inset.left))
|
|
90
|
+
start = -inset.left * full
|
|
91
|
+
end = full + start
|
|
92
|
+
} else if type(inset.left) == ratio {
|
|
93
|
+
let full = (100% + inset.right) / (1 - float(inset.left))
|
|
94
|
+
(start, end) = (-inset.left * full, 100% + inset.right)
|
|
95
|
+
} else if type(inset.right) == ratio {
|
|
96
|
+
let full = (100% + inset.left) / (1 - float(inset.right))
|
|
97
|
+
(start, end) = (-inset.left, full - inset.left)
|
|
98
|
+
} else {
|
|
99
|
+
(start, end) = (-inset.left, 100% + inset.right)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
line.with(
|
|
103
|
+
start: (start, 0%),
|
|
104
|
+
end: (end, 0%)
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
/*
|
|
108
|
+
* Function: showy-stroke()
|
|
109
|
+
*
|
|
110
|
+
* Description: Creates a stroke or set of strokes
|
|
111
|
+
* to use as borders.
|
|
112
|
+
*
|
|
113
|
+
* Parameters:
|
|
114
|
+
* + frame: The dictionary with frame settings
|
|
115
|
+
*/
|
|
116
|
+
#let showy-stroke(frame, ..overrides) = {
|
|
117
|
+
let (paint, dash, width) = (
|
|
118
|
+
frame.border-color,
|
|
119
|
+
frame.dash,
|
|
120
|
+
frame.thickness
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
let strokes = (:)
|
|
124
|
+
if type(width) != dictionary { // Set all borders at once
|
|
125
|
+
for side in ("top", "bottom", "left", "right") {
|
|
126
|
+
strokes.insert(side, (paint: paint, dash: dash, thickness: width))
|
|
127
|
+
}
|
|
128
|
+
} else { // Set each border individually
|
|
129
|
+
for pair in width {
|
|
130
|
+
strokes.insert(
|
|
131
|
+
pair.first(), // key
|
|
132
|
+
(paint: paint, dash: dash, thickness: pair.last())
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for pair in overrides.named() {
|
|
137
|
+
strokes.insert(
|
|
138
|
+
pair.first(),
|
|
139
|
+
(paint: paint, dash: dash, thickness: pair.last())
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
return strokes
|
|
143
143
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ShowyBox - A package for Typst
|
|
3
|
-
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
-
*
|
|
5
|
-
* lib/id.typ -- The package's file containing all the
|
|
6
|
-
* internal functions used to handle showybox id
|
|
7
|
-
*
|
|
8
|
-
* This file is under the MIT license. For more
|
|
9
|
-
* information see LICENSE on the package's main folder.
|
|
10
|
-
*/
|
|
11
|
-
|
|
1
|
+
/*
|
|
2
|
+
* ShowyBox - A package for Typst
|
|
3
|
+
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
+
*
|
|
5
|
+
* lib/id.typ -- The package's file containing all the
|
|
6
|
+
* internal functions used to handle showybox id
|
|
7
|
+
*
|
|
8
|
+
* This file is under the MIT license. For more
|
|
9
|
+
* information see LICENSE on the package's main folder.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
12
|
#let _showy-id = counter("showybox-id")
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ShowyBox - A package for Typst
|
|
3
|
-
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
-
*
|
|
5
|
-
* lib/pre-rendering.typ -- The package's file containing all
|
|
6
|
-
* the internal functions used for pre-rendering some components
|
|
7
|
-
* to get their dimensions or properties.
|
|
8
|
-
*
|
|
9
|
-
* This file is under the MIT license. For more
|
|
10
|
-
* information see LICENSE on the package's main folder.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
#import "id.typ": *
|
|
14
|
-
#import "sections.typ": *
|
|
15
|
-
|
|
16
|
-
/*
|
|
17
|
-
* Function: showy-pre-render-title()
|
|
18
|
-
*
|
|
19
|
-
* Description: Pre-renders the title emulating the conditions of
|
|
20
|
-
* the final container.
|
|
21
|
-
*
|
|
22
|
-
* Parameters:
|
|
23
|
-
* + sbox-props: Showybox properties
|
|
24
|
-
*/
|
|
25
|
-
#let showy-pre-render-title(sbox-props, id) = context {
|
|
26
|
-
let my-state = state("showybox-" + id, 0pt)
|
|
27
|
-
|
|
28
|
-
layout(size => {
|
|
29
|
-
// Get full container's width in a length type
|
|
30
|
-
let container-width = if type(sbox-props.width) == ratio {
|
|
31
|
-
sbox-props.width * size.width
|
|
32
|
-
} else {
|
|
33
|
-
sbox-props.width
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let pre-rendered = block(
|
|
37
|
-
spacing: 0pt,
|
|
38
|
-
width: container-width,
|
|
39
|
-
fill: yellow,
|
|
40
|
-
inset: (x: 1em),
|
|
41
|
-
showy-title(sbox-props),
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
let rendered-size = measure(pre-rendered, ..size)
|
|
45
|
-
|
|
46
|
-
// Store the height in the state
|
|
47
|
-
my-state.update(rendered-size.height)
|
|
48
|
-
})
|
|
49
|
-
//v(-(my-state.final(loc) + sbox-props.frame.thickness)/2)
|
|
50
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* ShowyBox - A package for Typst
|
|
3
|
+
* Pablo González Calderón and Showybox Contributors (c) 2023-2024
|
|
4
|
+
*
|
|
5
|
+
* lib/pre-rendering.typ -- The package's file containing all
|
|
6
|
+
* the internal functions used for pre-rendering some components
|
|
7
|
+
* to get their dimensions or properties.
|
|
8
|
+
*
|
|
9
|
+
* This file is under the MIT license. For more
|
|
10
|
+
* information see LICENSE on the package's main folder.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#import "id.typ": *
|
|
14
|
+
#import "sections.typ": *
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Function: showy-pre-render-title()
|
|
18
|
+
*
|
|
19
|
+
* Description: Pre-renders the title emulating the conditions of
|
|
20
|
+
* the final container.
|
|
21
|
+
*
|
|
22
|
+
* Parameters:
|
|
23
|
+
* + sbox-props: Showybox properties
|
|
24
|
+
*/
|
|
25
|
+
#let showy-pre-render-title(sbox-props, id) = context {
|
|
26
|
+
let my-state = state("showybox-" + id, 0pt)
|
|
27
|
+
|
|
28
|
+
layout(size => {
|
|
29
|
+
// Get full container's width in a length type
|
|
30
|
+
let container-width = if type(sbox-props.width) == ratio {
|
|
31
|
+
sbox-props.width * size.width
|
|
32
|
+
} else {
|
|
33
|
+
sbox-props.width
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let pre-rendered = block(
|
|
37
|
+
spacing: 0pt,
|
|
38
|
+
width: container-width,
|
|
39
|
+
fill: yellow,
|
|
40
|
+
inset: (x: 1em),
|
|
41
|
+
showy-title(sbox-props),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
let rendered-size = measure(pre-rendered, ..size)
|
|
45
|
+
|
|
46
|
+
// Store the height in the state
|
|
47
|
+
my-state.update(rendered-size.height)
|
|
48
|
+
})
|
|
49
|
+
//v(-(my-state.final(loc) + sbox-props.frame.thickness)/2)
|
|
50
|
+
}
|