-
Notifications
You must be signed in to change notification settings - Fork 1
/
resume.satyh
179 lines (140 loc) · 5.29 KB
/
resume.satyh
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
@require: math
@require: color
@require: enumitem/enumitem
@require: annot
module Resume : sig
val document : 'a -> block-text -> document
constraint 'a :: (|
name : inline-text;
location : inline-text;
phone : inline-text;
email : inline-text;
|)
direct \bold : [inline-text] inline-cmd
direct \color : [inline-text] inline-cmd
direct \emph : [inline-text] inline-cmd
direct \boldemph : [inline-text] inline-cmd
direct \href : [string; inline-text] inline-cmd
direct +p : [inline-text] block-cmd
direct +section : [inline-text; block-text] block-cmd
direct +what-where-when : [inline-text; inline-text; inline-text] block-cmd
direct +subsection : [block-text; block-text] block-cmd
direct +listing : [itemize] block-cmd
end = struct
let font-ratio-latin = 1.
let font-latin-roman = (`Junicode` , font-ratio-latin, 0.)
let font-latin-bold = (`Junicode-b` , font-ratio-latin, 0.)
let font-latin-italic = (`Junicode-it`, font-ratio-latin, 0.)
let font-latin-bold-italic = (`Junicode-b-it`, font-ratio-latin, 0.)
let std-color = Color.rgb 0.17 0.22 0.34
let ctx-set-color ctx = ctx |> set-text-color std-color
let ctx-font-size-lg ctx = ctx |> set-font-size ((get-font-size ctx) *' 1.8)
let ctx-font-size-md ctx = ctx |> set-font-size ((get-font-size ctx) *' 1.3)
let ctx-mb-lg ctx = ctx |> set-paragraph-margin 0.pt 16.pt
let ctx-mb-md ctx = ctx |> set-paragraph-margin 0.pt 12.pt
let ctx-mb-sm ctx = ctx |> set-paragraph-margin 0.pt 4.pt
let ctx-mbt-md ctx = ctx |> set-paragraph-margin 6.pt 8.pt
let-inline ctx \color it = read-inline (ctx |> ctx-set-color) it
let-inline ctx \bold it =
let ctx-bold = ctx |> set-font Latin font-latin-bold in
read-inline ctx-bold it
let-inline ctx \emph it =
let ctx = ctx |> set-font Latin font-latin-italic in
read-inline ctx it
let-inline ctx \boldemph it =
let ctx = ctx |> set-font Latin font-latin-bold-italic in
read-inline ctx it
let-inline ctx \underline it =
let thickness = 0.4pt in
let color = Color.gray 0.3 in
let strokef = stroke thickness color in
read-inline ctx it
|> inline-frame-outer (0.pt, 0.pt, 0.pt, 0.pt) (fun (x, y) w h d -> [
Gr.line (x, y -' d -' 1.1pt) (x +' w, y -' d -' 1.1pt) |> strokef
])
let-inline \href url it = {\underline{\href(url){#it;}}}
let-inline ctx \lg it = read-inline (ctx |> ctx-font-size-lg) it
let-inline ctx \md it = read-inline (ctx |> ctx-font-size-md) it
let-block ctx +p it =
let ib-inner = read-inline ctx it in
line-break true true ctx (ib-inner ++ inline-fil)
let-block ctx +right-align it =
inline-fil ++ (read-inline ctx it)
|> line-break true true ctx
let-block ctx +center it =
inline-fil ++ (read-inline ctx it) ++ inline-fil
|> line-break true true ctx
let-block ctx +long-underline it =
let thickness = 0.5pt in
let strokef = stroke thickness std-color in
let ib = (read-inline ctx it) ++ inline-fil in
ib
|> inline-frame-outer (0.pt, 0.pt, 0.pt, 3.pt) (fun (x, y) w h d -> [
Gr.line (x, y -' d) (x +' w, y -' d) |> strokef
])
|> line-break true true ctx
let-block ctx +section header-it body-bt =
let ctx = ctx |> ctx-mb-sm in
let header-bb =
'<+long-underline{\color{\bold{\md{#header-it;}}}}>
|> read-block (ctx |> ctx-mbt-md)
in
let body-bb = body-bt |> read-block ctx
in
header-bb +++ body-bb
let multicolumn ctx items =
let text-width = get-text-width ctx in
items
|> List.map (fun (ratio, bt) -> (text-width *' ratio, bt))
|> List.fold-left (fun acc-it (wid, bt) -> (
acc-it ++ (embed-block-top ctx wid (fun ctx -> read-block ctx bt)))) inline-nil
|> line-break true true ctx
let-block ctx +what-where-when what-it where-it when-it =
multicolumn ctx [
(0.333, '<+p{\bold{#what-it;}}>);
(0.333, '<+center{\bold{#where-it;}}>);
(0.333, '<+right-align{#when-it;}>);
]
let-block ctx +subsection header-bt body-bt =
read-block (ctx |> ctx-mb-sm) header-bt
+++ read-block (ctx |> ctx-mb-md) body-bt
let-block ctx +listing item =
let listing-bb =
'<+EnumitemAlias.listing?:(EnumitemAlias.white-bullet)(item);>
|> read-block (ctx |> ctx-mb-sm)
in
let blank-line-bb = read-block (ctx |> ctx-mb-sm) '<+p{}> in
listing-bb +++ blank-line-bb
let get-standard-context wid =
get-initial-context wid (command \math)
|> set-font Latin font-latin-roman
|> set-leading 0.pt
|> set-min-gap-of-lines 2.5pt
|> ctx-mb-lg
|> set-hyphen-penalty 1000
let document record bt =
let name = record#name in
let location = record#location in
let phone = record#phone in
let email = record#email in
let ctx = get-standard-context 490pt in
let header = multicolumn (ctx |> ctx-mb-lg) [
(0.4, '<+p{\color{\bold{\lg{#name;}}}}>);
(0.6, '<+right-align{#location; \|\ #phone; \|\ #email;}>)
]
in
let bb = read-block ctx bt in
page-break A4Paper
(fun _ -> (|
text-origin = (50pt, 40pt);
text-height = 780pt;
|))
(fun _ -> (|
header-origin = (0pt, 0pt);
header-content = block-nil;
footer-origin = (0pt, 0pt);
footer-content = block-nil;
|))
(header +++ bb)
end
let document = Resume.document