-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyntaxHighlighting.mdeck
More file actions
377 lines (282 loc) · 4.59 KB
/
SyntaxHighlighting.mdeck
File metadata and controls
377 lines (282 loc) · 4.59 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
---
format: codeck.mdeck
version: 1
theme: midnight
codex:
sandbox: read-only
model: "gpt-5.5"
reasoning: medium
---
# Syntax Highlighting Gallery
Use fenced code blocks with a language after the opening fence.
Examples in this deck use language labels like `swift`, `json`, `html`, `diff`, and `plaintext`.
---
# Swift
```swift
import SwiftUI
@MainActor
struct LessonCard: View {
let title: String
let progress: Double = 0.75
var body: some View {
VStack(alignment: .leading) {
Text(title)
ProgressView(value: progress)
}
}
}
```
---
# JavaScript
```javascript
const decks = ["intro", "syntax", "wrap-up"];
export async function loadDeck(id) {
if (!decks.includes(id)) {
throw new Error(`Unknown deck: ${id}`);
}
return await fetch(`/decks/${id}.mdeck`).then(response => response.text());
}
```
---
# TypeScript
```typescript
type SlideState = "idle" | "running" | "completed";
interface SlideSummary {
id: string;
title: string;
state: SlideState;
}
function isRunnable(slide: SlideSummary): boolean {
return slide.state !== "running";
}
```
---
# JSX and TSX
```tsx
export function DeckToolbar({ title, onRunAll }: Props) {
return (
<header className="toolbar">
<strong>{title}</strong>
<button onClick={onRunAll}>Run all</button>
</header>
);
}
```
---
# Python
```python
from dataclasses import dataclass
@dataclass
class Deck:
title: str
slide_count: int = 0
def describe(self) -> str:
return f"{self.title}: {self.slide_count} slides"
```
---
# Shell
```bash
#!/usr/bin/env bash
set -euo pipefail
deck="${1:-Examples/SyntaxHighlighting.mdeck}"
if [[ -f "$deck" ]]; then
echo "Opening $deck"
fi
```
```powershell
$deck = "Examples/SyntaxHighlighting.mdeck"
if (Test-Path $deck) {
Write-Output "Opening $deck"
}
```
---
# JSON
```json
{
"format": "codeck.mdeck",
"version": 1,
"features": {
"syntaxHighlighting": true,
"languages": 24
}
}
```
---
# YAML and TOML
```yaml
format: codeck.mdeck
version: 1
theme: midnight
codex:
sandbox: read-only
reasoning: medium
```
```toml
format = "codeck.mdeck"
version = 1
theme = "midnight"
syntax_highlighting = true
```
---
# HTML and XML
```html
<section class="slide" data-theme="midnight">
<h1>Syntax Highlighting</h1>
<button type="button">Run all</button>
</section>
```
```xml
<deck format="codeck.mdeck">
<slide id="syntax-gallery">Highlighted XML</slide>
</deck>
```
---
# CSS and SCSS
```css
.slide {
display: grid;
gap: 1rem;
color: var(--code-fg);
}
.slide:hover {
border-color: currentColor;
}
```
```scss
$accent: #7bdff2;
.toolbar {
&:hover {
color: $accent;
}
}
```
---
# Markdown
```markdown
# Lesson Plan
- Show the fence
- Name the language
- Check the preview
> Code blocks keep their original spacing.
```
---
# Diff
```diff
@@ -1,5 +1,6 @@
struct Slide {
- let markdown: String
+ let markdown: String
+ let language: String?
}
```
---
# SQL
```sql
select title, count(*) as slide_count
from decks
where theme = 'midnight'
group by title
order by slide_count desc
limit 5;
```
---
# Rust
```rust
pub struct Slide<'a> {
pub title: &'a str,
pub visible: bool,
}
impl<'a> Slide<'a> {
pub fn label(&self) -> String {
format!("{}: {}", self.title, self.visible)
}
}
```
---
# Go
```go
package main
import "fmt"
type Slide struct {
Title string
Done bool
}
func main() {
fmt.Println(Slide{Title: "Syntax", Done: true})
}
```
---
# Java and Kotlin
```java
public final class Slide {
private final String title;
public Slide(String title) {
this.title = title;
}
}
```
```kotlin
data class Slide(
val title: String,
val visible: Boolean = true
)
```
---
# C and C++
```c
#include <stdio.h>
int main(void) {
const char *title = "Syntax";
printf("%s\n", title);
return 0;
}
```
```cpp
#include <string>
struct Slide {
std::string title;
bool visible = true;
};
```
---
# Objective-C and C Sharp
```objective-c
@interface Slide : NSObject
@property (nonatomic, copy) NSString *title;
@end
@implementation Slide
@end
```
```csharp
public sealed class Slide {
public string Title { get; init; } = "Syntax";
public bool Visible { get; init; } = true;
}
```
---
# Ruby
```ruby
class Slide
attr_reader :title
def initialize(title)
@title = title
end
end
```
---
# PHP
```php
<?php
final class Slide {
public function __construct(
public string $title,
public bool $visible = true,
) {}
}
```
---
# Plain Text
```plaintext
Plain text intentionally skips syntax spans.
Use this for terminal transcripts, logs, or prose.
```