-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.typ
More file actions
731 lines (671 loc) · 23.2 KB
/
example.typ
File metadata and controls
731 lines (671 loc) · 23.2 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
// Simple numbering for non-book documents
#let equation-numbering = "(1)"
#let callout-numbering = "1"
#let subfloat-numbering(n-super, subfloat-idx) = {
numbering("1a", n-super, subfloat-idx)
}
// Theorem configuration for theorion
// Simple numbering for non-book documents (no heading inheritance)
#let theorem-inherited-levels = 0
// Theorem numbering format (can be overridden by extensions for appendix support)
// This function returns the numbering pattern to use
#let theorem-numbering(loc) = "1.1"
// Default theorem render function
#let theorem-render(prefix: none, title: "", full-title: auto, body) = {
if full-title != "" and full-title != auto and full-title != none {
strong[#full-title.]
h(0.5em)
}
body
}
// Some definitions presupposed by pandoc's typst output.
#let content-to-string(content) = {
if content.has("text") {
content.text
} else if content.has("children") {
content.children.map(content-to-string).join("")
} else if content.has("body") {
content-to-string(content.body)
} else if content == [ ] {
" "
}
}
#let horizontalrule = line(start: (25%, 0%), end: (75%, 0%))
#let endnote(num, contents) = [
#stack(dir: ltr, spacing: 3pt, super[#num], contents)
]
// Use nested show rule to preserve list structure for PDF/UA-1 accessibility
// See: https://github.com/quarto-dev/quarto-cli/pull/13249#discussion_r2678934509
#show terms: it => {
show terms.item: item => {
set text(weight: "bold")
item.term
block(inset: (left: 1.5em, top: -0.4em))[#item.description]
}
it
}
// Prevent breaking inside definition items, i.e., keep term and description together.
#show terms.item: set block(breakable: false)
// Some quarto-specific definitions.
#show raw.where(block: true): set block(
fill: luma(230),
width: 100%,
inset: 8pt,
radius: 2pt,
)
#let block_with_new_content(old_block, new_content) = {
let fields = old_block.fields()
let _ = fields.remove("body")
if fields.at("below", default: none) != none {
// TODO: this is a hack because below is a "synthesized element"
// according to the experts in the typst discord...
fields.below = fields.below.abs
}
block.with(..fields)(new_content)
}
#let empty(v) = {
if type(v) == str {
// two dollar signs here because we're technically inside
// a Pandoc template :grimace:
v.matches(regex("^\\s*$")).at(0, default: none) != none
} else if type(v) == content {
if v.at("text", default: none) != none {
return empty(v.text)
}
for child in v.at("children", default: ()) {
if not empty(child) {
return false
}
}
return true
}
}
// Subfloats
// This is a technique that we adapted from https://github.com/tingerrr/subpar/
#let quartosubfloatcounter = counter("quartosubfloatcounter")
#let quarto_super(
kind: str,
caption: none,
label: none,
supplement: str,
position: none,
subcapnumbering: "(a)",
body,
) = {
context {
let figcounter = counter(figure.where(kind: kind))
let n-super = figcounter.get().first() + 1
set figure.caption(position: position)
[#figure(
kind: kind,
supplement: supplement,
caption: caption,
{
show figure.where(kind: kind): set figure(numbering: _ => {
let subfloat-idx = quartosubfloatcounter.get().first() + 1
subfloat-numbering(n-super, subfloat-idx)
})
show figure.where(kind: kind): set figure.caption(position: position)
show figure: it => {
let num = numbering(subcapnumbering, n-super, quartosubfloatcounter.get().first() + 1)
show figure.caption: it => block({
num.slice(2) // I don't understand why the numbering contains output that it really shouldn't, but this fixes it shrug?
[ ]
it.body
})
quartosubfloatcounter.step()
it
counter(figure.where(kind: it.kind)).update(n => n - 1)
}
quartosubfloatcounter.update(0)
body
},
)#label]
}
}
// callout rendering
// this is a figure show rule because callouts are crossreferenceable
#show figure: it => {
if type(it.kind) != str {
return it
}
let kind_match = it.kind.matches(regex("^quarto-callout-(.*)")).at(0, default: none)
if kind_match == none {
return it
}
let kind = kind_match.captures.at(0, default: "other")
kind = upper(kind.first()) + kind.slice(1)
// now we pull apart the callout and reassemble it with the crossref name and counter
// when we cleanup pandoc's emitted code to avoid spaces this will have to change
let old_callout = it.body.children.at(1).body.children.at(1)
let old_title_block = old_callout.body.children.at(0)
let children = old_title_block.body.body.children
let old_title = if children.len() == 1 {
children.at(0) // no icon: title at index 0
} else {
children.at(1) // with icon: title at index 1
}
// TODO use custom separator if available
// Use the figure's counter display which handles chapter-based numbering
// (when numbering is a function that includes the heading counter)
let callout_num = it.counter.display(it.numbering)
let new_title = if empty(old_title) {
[#kind #callout_num]
} else {
[#kind #callout_num: #old_title]
}
let new_title_block = block_with_new_content(
old_title_block,
block_with_new_content(
old_title_block.body,
if children.len() == 1 {
new_title // no icon: just the title
} else {
children.at(0) + new_title // with icon: preserve icon block + new title
},
),
)
align(left, block_with_new_content(old_callout, block(below: 0pt, new_title_block) + old_callout.body.children.at(1)))
}
// 2023-10-09: #fa-icon("fa-info") is not working, so we'll eval "#fa-info()" instead
#let callout(
body: [],
title: "Callout",
background_color: rgb("#dddddd"),
icon: none,
icon_color: black,
body_background_color: white,
) = {
block(
breakable: false,
fill: background_color,
stroke: (paint: icon_color, thickness: 0.5pt, cap: "round"),
width: 100%,
radius: 2pt,
block(
inset: 1pt,
width: 100%,
below: 0pt,
block(
fill: background_color,
width: 100%,
inset: 8pt,
)[#if icon != none [#text(icon_color, weight: 900)[#icon] ]#title],
)
+ if (body != []) {
block(
inset: 1pt,
width: 100%,
block(fill: body_background_color, width: 100%, inset: 8pt, body),
)
},
)
}
// syntax highlighting functions from skylighting:
/* Function definitions for syntax highlighting generated by skylighting: */
#let EndLine() = raw("\n")
#let Skylighting(fill: none, number: false, start: 1, sourcelines) = {
let blocks = []
let lnum = start - 1
let bgcolor = rgb("#24292e")
for ln in sourcelines {
if number {
lnum = lnum + 1
blocks = blocks + box(width: if start + sourcelines.len() > 999 { 30pt } else { 24pt }, text([ #lnum ]))
}
blocks = blocks + ln + EndLine()
}
block(fill: bgcolor, width: 100%, inset: 8pt, radius: 2pt, blocks)
}
#let AlertTok(s) = text(weight: "bold", fill: rgb("#ff5555"), raw(s))
#let AnnotationTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let AttributeTok(s) = text(fill: rgb("#f97583"), raw(s))
#let BaseNTok(s) = text(fill: rgb("#79b8ff"), raw(s))
#let BuiltInTok(s) = text(fill: rgb("#f97583"), raw(s))
#let CharTok(s) = text(fill: rgb("#9ecbff"), raw(s))
#let CommentTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let CommentVarTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let ConstantTok(s) = text(fill: rgb("#79b8ff"), raw(s))
#let ControlFlowTok(s) = text(fill: rgb("#f97583"), raw(s))
#let DataTypeTok(s) = text(fill: rgb("#f97583"), raw(s))
#let DecValTok(s) = text(fill: rgb("#79b8ff"), raw(s))
#let DocumentationTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let ErrorTok(s) = underline(text(fill: rgb("#ff5555"), raw(s)))
#let ExtensionTok(s) = text(weight: "bold", fill: rgb("#f97583"), raw(s))
#let FloatTok(s) = text(fill: rgb("#79b8ff"), raw(s))
#let FunctionTok(s) = text(fill: rgb("#b392f0"), raw(s))
#let ImportTok(s) = text(fill: rgb("#9ecbff"), raw(s))
#let InformationTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let KeywordTok(s) = text(fill: rgb("#f97583"), raw(s))
#let NormalTok(s) = text(fill: rgb("#e1e4e8"), raw(s))
#let OperatorTok(s) = text(fill: rgb("#e1e4e8"), raw(s))
#let OtherTok(s) = text(fill: rgb("#b392f0"), raw(s))
#let PreprocessorTok(s) = text(fill: rgb("#f97583"), raw(s))
#let RegionMarkerTok(s) = text(fill: rgb("#6a737d"), raw(s))
#let SpecialCharTok(s) = text(fill: rgb("#79b8ff"), raw(s))
#let SpecialStringTok(s) = text(fill: rgb("#9ecbff"), raw(s))
#let StringTok(s) = text(fill: rgb("#9ecbff"), raw(s))
#let VariableTok(s) = text(fill: rgb("#ffab70"), raw(s))
#let VerbatimStringTok(s) = text(fill: rgb("#9ecbff"), raw(s))
#let WarningTok(s) = text(fill: rgb("#ff5555"), raw(s))
#let article(
title: none,
subtitle: none,
authors: none,
keywords: (),
date: none,
abstract-title: none,
abstract: none,
thanks: none,
cols: 1,
lang: "en",
region: "US",
font: none,
fontsize: 11pt,
title-size: 1.5em,
subtitle-size: 1.25em,
heading-family: none,
heading-weight: "bold",
heading-style: "normal",
heading-color: black,
heading-line-height: 0.65em,
mathfont: none,
codefont: none,
linestretch: 1,
sectionnumbering: none,
linkcolor: none,
citecolor: none,
filecolor: none,
toc: false,
toc_title: none,
toc_depth: none,
toc_indent: 1.5em,
doc,
) = {
// Set document metadata for PDF accessibility
set document(title: title, keywords: keywords)
set document(
author: authors.map(author => content-to-string(author.name)).join(", ", last: " & "),
) if authors != none and authors != ()
set par(
justify: true,
leading: linestretch * 0.65em,
)
set text(lang: lang, region: region, size: fontsize)
set text(font: font) if font != none
show math.equation: set text(font: mathfont) if mathfont != none
show raw: set text(font: codefont) if codefont != none
set heading(numbering: sectionnumbering)
show link: set text(fill: rgb(content-to-string(linkcolor))) if linkcolor != none
show ref: set text(fill: rgb(content-to-string(citecolor))) if citecolor != none
show link: this => {
if filecolor != none and type(this.dest) == label {
text(this, fill: rgb(content-to-string(filecolor)))
} else {
text(this)
}
}
place(
top,
float: true,
scope: "parent",
clearance: 4mm,
block(below: 1em, width: 100%)[
#if title != none {
align(center, block(inset: 2em)[
#set par(leading: heading-line-height) if heading-line-height != none
#set text(font: heading-family) if heading-family != none
#set text(weight: heading-weight)
#set text(style: heading-style) if heading-style != "normal"
#set text(fill: heading-color) if heading-color != black
#text(size: title-size)[#title #if thanks != none {
footnote(thanks, numbering: "*")
counter(footnote).update(n => n - 1)
}]
#(
if subtitle != none {
parbreak()
text(size: subtitle-size)[#subtitle]
}
)
])
}
#if authors != none and authors != () {
let count = authors.len()
let ncols = calc.min(count, 3)
grid(
columns: (1fr,) * ncols,
row-gutter: 1.5em,
..authors.map(author => align(center)[
#author.name \
#author.affiliation \
#author.email
])
)
}
#if date != none {
align(center)[#block(inset: 1em)[
#date
]]
}
#if abstract != none {
block(inset: 2em)[
#text(weight: "semibold")[#abstract-title] #h(1em) #abstract
]
}
],
)
if toc {
let title = if toc_title == none {
auto
} else {
toc_title
}
block(above: 0em, below: 2em)[
#outline(
title: toc_title,
depth: toc_depth,
indent: toc_indent,
);
]
}
doc
}
#set table(
inset: 6pt,
stroke: none,
)
#let brand-color = (:)
#let brand-color-background = (:)
#let brand-logo = (:)
#set page(
paper: "a4",
margin: (x: 2.5cm, y: 2.5cm),
numbering: "1",
columns: 1,
)
#show: doc => article(
title: [Code Window],
subtitle: [Quarto Extension],
authors: (
(name: [Mickaël CANOUIL, #emph[Ph.D.]], affiliation: [], email: []),
),
toc_title: [Table of contents],
toc_depth: 3,
doc,
)
#show figure.where(kind: "quarto-float-lst"): set align(start)
// skylighting-typst-fix override
#let Skylighting(
fill: none,
number: false,
start: 1,
sourcelines,
) = {
let bgcolor = if fill != none { fill } else { rgb("#24292e") }
let blocks = []
let lnum = start - 1
let has-gutter = start + sourcelines.len() > 999
for ln in sourcelines {
if number {
lnum = lnum + 1
blocks = (
blocks
+ box(
width: if has-gutter { 30pt } else { 24pt },
text([ #lnum ]),
)
)
}
blocks = blocks + ln + EndLine()
}
block(
fill: bgcolor,
width: 100%,
inset: 8pt,
radius: 2pt,
stroke: none,
blocks,
)
}
#let code-window(content, filename: none, is-auto: false, style: "macos") = {
let border-colour = luma(200)
let surface-fill = luma(237)
let muted-colour = luma(120)
let filename-label = if filename != none {
text(
size: if is-auto { 0.7em } else { 0.85em },
weight: 500,
fill: muted-colour,
if is-auto { upper(filename) } else { filename },
)
}
let traffic-lights = box(
inset: (right: 0.5em),
stack(
dir: ltr,
spacing: 0.425em,
circle(radius: 0.425em, fill: rgb("#ff5f56"), stroke: none),
circle(radius: 0.425em, fill: rgb("#ffbd2e"), stroke: none),
circle(radius: 0.425em, fill: rgb("#27c93f"), stroke: none),
),
)
let window-buttons = box(
inset: (left: 0.5em),
{
set line(stroke: 1pt + muted-colour)
stack(
dir: ltr,
spacing: 0.8em,
// Minimise (horizontal line)
box(width: 0.6em, height: 0.6em, align(horizon, line(length: 100%))),
// Maximise (square)
box(width: 0.6em, height: 0.6em, stroke: 1pt + muted-colour),
// Close (x)
box(width: 0.6em, height: 0.6em, {
place(line(start: (0%, 0%), end: (100%, 100%)))
place(line(start: (100%, 0%), end: (0%, 100%)))
}),
)
},
)
let title-bar = if style == "macos" {
grid(
columns: (auto, 1fr),
align: (left + horizon, right + horizon),
gutter: 0.5em,
stroke: 0pt,
traffic-lights, filename-label,
)
} else if style == "windows" {
grid(
columns: (1fr, auto),
align: (left + horizon, right + horizon),
gutter: 0.5em,
stroke: 0pt,
filename-label, window-buttons,
)
} else {
// default: plain filename, left-aligned
filename-label
}
block(
width: 100%,
stroke: 1pt + border-colour,
radius: 8pt,
clip: true,
{
block(
width: 100%,
fill: surface-fill,
inset: (x: 1em, y: 0.6em),
below: 0pt,
radius: 0pt,
stroke: (bottom: 1pt + border-colour),
sticky: true,
title-bar,
)
// Strip code block chrome so content fills flush against the window body.
// set block() provides defaults for Skylighting blocks (explicit fill preserved).
// show raw overrides the document-level raw block styling (fill, radius).
{
set block(
width: 100%,
inset: 8pt,
radius: 0pt,
stroke: none,
above: 0pt,
below: 0pt,
)
show raw.where(block: true): set block(
fill: none,
width: 100%,
radius: 0pt,
stroke: none,
above: 0pt,
below: 0pt,
)
content
}
},
)
}
#figure(
[
#code-window(filename: "fibonacci.py", is-auto: false, style: "macos")[
#Skylighting((
[#KeywordTok("def");#NormalTok(" fibonacci(n: ");#BuiltInTok("int");#NormalTok(") ");#OperatorTok(
"->",
);#NormalTok(" ");#BuiltInTok("int");#NormalTok(":");],
[#NormalTok(" ");#CommentTok("\"\"\"Calculate the nth Fibonacci number.\"\"\"");],
[#NormalTok(" ");#ControlFlowTok("if");#NormalTok(" n ");#OperatorTok("<=");#NormalTok(" ");#DecValTok(
"1",
);#NormalTok(":");],
[#NormalTok(" ");#ControlFlowTok("return");#NormalTok(" n");],
[#NormalTok(" ");#ControlFlowTok("return");#NormalTok(" fibonacci(n ");#OperatorTok("-");#NormalTok(
" ",
);#DecValTok("1");#NormalTok(") ");#OperatorTok("+");#NormalTok(" fibonacci(n ");#OperatorTok("-");#NormalTok(
" ",
);#DecValTok("2");#NormalTok(")");],
));
]
],
caption: figure.caption(
position: top,
[
This is code
],
),
kind: "quarto-float-lst",
supplement: "Listing",
)
<lst-one>
= Explicit Filename
<explicit-filename>
Code blocks with a #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("filename");] attribute display a window header with the filename. The decoration style depends on the #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("style");] option (default: #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("\"macos\"");]).
#code-window(filename: "fibonacci.py", is-auto: false, style: "macos")[
#Skylighting((
[#KeywordTok("def");#NormalTok(" fibonacci(n: ");#BuiltInTok("int");#NormalTok(") ");#OperatorTok("->");#NormalTok(
" ",
);#BuiltInTok("int");#NormalTok(":");],
[#NormalTok(" ");#CommentTok("\"\"\"Calculate the nth Fibonacci number.\"\"\"");],
[#NormalTok(" ");#ControlFlowTok("if");#NormalTok(" n ");#OperatorTok("<=");#NormalTok(" ");#DecValTok(
"1",
);#NormalTok(":");],
[#NormalTok(" ");#ControlFlowTok("return");#NormalTok(" n");],
[#NormalTok(" ");#ControlFlowTok("return");#NormalTok(" fibonacci(n ");#OperatorTok("-");#NormalTok(
" ",
);#DecValTok("1");#NormalTok(") ");#OperatorTok("+");#NormalTok(" fibonacci(n ");#OperatorTok("-");#NormalTok(
" ",
);#DecValTok("2");#NormalTok(")");],
));
]
#code-window(filename: "analysis.R", is-auto: false, style: "macos")[
#Skylighting((
[#CommentTok("# Load data and create summary");],
[#NormalTok("data ");#OtherTok("<-");#NormalTok(" ");#FunctionTok("read.csv");#NormalTok("(");#StringTok(
"\"data.csv\"",
);#NormalTok(")");],
[#FunctionTok("summary");#NormalTok("(data)");],
));
]
= Auto-Generated Filename
<auto-generated-filename>
With #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("auto-filename: true");] (the default), code blocks without explicit filenames automatically show the language name in small-caps styling.
#code-window(filename: "python", is-auto: true, style: "macos")[
#Skylighting((
[#KeywordTok("def");#NormalTok(" greet(name: ");#BuiltInTok("str");#NormalTok(") ");#OperatorTok("->");#NormalTok(
" ",
);#BuiltInTok("str");#NormalTok(":");],
[#NormalTok(" ");#CommentTok("\"\"\"Return a greeting message.\"\"\"");],
[#NormalTok(" ");#ControlFlowTok("return");#NormalTok(" ");#SpecialStringTok("f\"Hello, ");#SpecialCharTok(
"{",
);#NormalTok("name");#SpecialCharTok("}");#SpecialStringTok("!\"");],
));
]
#code-window(filename: "r", is-auto: true, style: "macos")[
#Skylighting((
[#CommentTok("# Create sample data");],
[#NormalTok("data ");#OtherTok("<-");#NormalTok(" ");#FunctionTok("data.frame");#NormalTok("(");],
[#NormalTok(" ");#AttributeTok("x =");#NormalTok(" ");#DecValTok("1");#SpecialCharTok(":");#DecValTok(
"10",
);#NormalTok(",");],
[#NormalTok(" ");#AttributeTok("y =");#NormalTok(" ");#FunctionTok("rnorm");#NormalTok("(");#DecValTok(
"10",
);#NormalTok(")");],
[#NormalTok(")");],
[#FunctionTok("summary");#NormalTok("(data)");],
));
]
#code-window(filename: "bash", is-auto: true, style: "macos")[
#Skylighting(([#CommentTok("#!/bin/bash");], [#BuiltInTok("echo");#NormalTok(" ");#StringTok("\"Hello, World!\"");]));
]
= Plain Code Block
<plain-code-block>
Code blocks without a language are not affected by the extension.
#Skylighting((
[#NormalTok("This is a plain code block without any language specified.");],
[#NormalTok("No window decoration is applied here.");],
));
= Disabled Auto-Filename
<disabled-auto-filename>
To disable auto-generated filenames, set #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("auto-filename: false");] in the extension configuration. Only code blocks with an explicit #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("filename");] attribute will display window decorations.
= Window Styles
<window-styles>
Three decoration styles are available via the #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("style");] option. The global style can be set in the document configuration. Individual blocks can override the style with the #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("code-window-style");] attribute.
== macOS Style (default)
<macos-style-default>
Traffic light buttons on the left, filename on the right.
#code-window(filename: "macos-example.py", is-auto: false, style: "macos")[
#Skylighting(([#BuiltInTok("print");#NormalTok("(");#StringTok("\"macOS style window\"");#NormalTok(")");],));
]
== Windows Style
<windows-style>
Minimise, maximise, and close buttons on the right, filename on the left.
#code-window(filename: "windows-example.py", is-auto: false, style: "windows")[
#Skylighting(([#BuiltInTok("print");#NormalTok("(");#StringTok("\"Windows style window\"");#NormalTok(")");],));
]
== Default Style
<default-style>
Plain filename on the left, no window decorations.
#code-window(filename: "default-example.py", is-auto: false, style: "default")[
#Skylighting(([#BuiltInTok("print");#NormalTok("(");#StringTok("\"Default style window\"");#NormalTok(")");],));
]
== Configuration
<configuration>
Set the global style in the document front matter:
#code-window(filename: "yaml", is-auto: true, style: "macos")[
#Skylighting((
[#FunctionTok("extensions");#KeywordTok(":");],
[#AttributeTok(" ");#FunctionTok("code-window");#KeywordTok(":");],
[#AttributeTok(" ");#FunctionTok("style");#KeywordTok(":");#AttributeTok(" ");#StringTok("\"macos\"");],
));
]
Override per block with the #box(fill: rgb("#24292e"), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, stroke: none)[#NormalTok("code-window-style");] attribute:
#code-window(filename: "markdown", is-auto: true, style: "macos")[
#Skylighting((
[#InformationTok("```{.python filename=\"example.py\" code-window-style=\"windows\"}");],
[#BuiltInTok("print");#NormalTok("(");#StringTok("\"Windows style for this block only\"");#NormalTok(")");],
[#InformationTok("```");],
));
]