Skip to content

Commit a35a9dd

Browse files
committed
Create {myst:static} directive first draft
1 parent 8ce6f46 commit a35a9dd

File tree

3 files changed

+97
-36
lines changed

3 files changed

+97
-36
lines changed

assets/styles/style.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,42 @@ body {
99
[aria-label="Document Outline"] {
1010
max-height: calc(100vh - 100px) !important;
1111
}
12+
13+
.myst-static-input-wrapper {
14+
border: 1px solid #ccc;
15+
}
16+
17+
.myst-static-input-wrapper::before {
18+
content: "📥 MyST input";
19+
display: block;
20+
background-color: #f5f5f5;
21+
border-bottom: 1px solid #ccc;
22+
padding: 8px 12px;
23+
font-weight: bold;
24+
font-size: 14px;
25+
color: #333;
26+
margin: 0;
27+
}
28+
29+
.myst-static-output-wrapper {
30+
border: 1px solid #ccc;
31+
margin-bottom: 20px;
32+
}
33+
34+
.myst-static-output-wrapper::before {
35+
content: "📤 MyST output";
36+
display: block;
37+
background-color: #f5f5f5;
38+
border-bottom: 1px solid #ccc;
39+
padding: 8px 12px;
40+
font-weight: bold;
41+
font-size: 14px;
42+
color: #333;
43+
margin: 0;
44+
}
45+
46+
.myst-static-content {
47+
padding-left: 12px;
48+
padding-right: 12px;
49+
margin: 0;
50+
}

for-instructors/helpers.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ directives that will save some time authoring certain repeated elements.
55

66
## Git commit checkpoint directive
77

8-
```myst
8+
```{myst:static}
99
:::{gitCommitCheckpoint} my commit message
1010
:::
1111
```
1212

13-
:::{gitCommitCheckpoint} my commit message
14-
:::
15-
1613

1714
## "You should notice..." directive
1815

19-
``````myst
16+
``````{myst:static}
2017
:::{youShouldNotice}
2118
...the `{youShouldNotice}` directive fully supports markdown in the body.
2219
This means you can, for example include some code:
@@ -26,12 +23,3 @@ print("Some code!")
2623
```
2724
:::
2825
``````
29-
30-
:::{youShouldNotice}
31-
...the `{youShouldNotice}` directive fully supports markdown in the body.
32-
This means you can, for example include some code:
33-
34-
```python
35-
print("Some code!")
36-
```
37-
:::

plugin-custom-directives.mjs

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
const gitCommitDirective = {
2-
name: "gitCommitCheckpoint",
3-
doc: "Renders a consistent callout when the learner should do a Git commit.",
2+
name: 'gitCommitCheckpoint',
3+
doc: 'Renders a consistent callout when the learner should do a Git commit.',
44
arg: {
55
type: String,
6-
doc: "Commit message",
6+
doc: 'Commit message',
77
},
88
run(data) {
99
return [{
10-
type: "admonition",
11-
kind: "important",
10+
type: 'admonition',
11+
kind: 'important',
1212
icon: false,
1313
children: [
1414
{
15-
type: "admonitionTitle",
15+
type: 'admonitionTitle',
1616
children: [{
17-
type: "text",
18-
value: "💾 Commit & push to GitHub",
17+
type: 'text',
18+
value: '💾 Commit & push to GitHub',
1919
}],
2020
},
2121
{
22-
type: "code",
23-
lang: "bash",
24-
value: `git add .\ngit commit -m "${data.arg}"\ngit push -u origin main`,
22+
type: 'code',
23+
lang: 'bash',
24+
value: `git add .\ngit commit -m '${data.arg}'\ngit push -u origin main`,
2525
},
2626
],
2727
}];
2828
},
2929
};
3030

3131
const youShouldNoticeDirective = {
32-
name: "youShouldNotice",
33-
doc: "Renders a consistent callout when the learner should notice something.",
32+
name: 'youShouldNotice',
33+
doc: 'Renders a consistent callout when the learner should notice something.',
3434
body: {
3535
type: 'myst',
3636
},
3737
run(data) {
3838
return [{
39-
type: "admonition",
40-
kind: "important",
39+
type: 'admonition',
40+
kind: 'important',
4141
icon: false,
42-
class: "simple",
42+
class: 'simple',
4343
children: [
4444
{
45-
type: "admonitionTitle",
45+
type: 'admonitionTitle',
4646
children: [{
47-
type: "text",
48-
value: "👀 You should notice...",
47+
type: 'text',
48+
value: '👀 You should notice...',
4949
}],
5050
},
5151
...data.body,
@@ -54,9 +54,43 @@ const youShouldNoticeDirective = {
5454
},
5555
};
5656

57+
const mystDemoStatic = {
58+
name: 'myst:static',
59+
doc: 'A static/pre-rendered version of the `{myst}` directive which supports plugins.',
60+
body: {
61+
type: 'myst',
62+
},
63+
run(data) {
64+
return [
65+
{
66+
type: "div",
67+
class: "myst-static-input-wrapper",
68+
children: [{
69+
type: "div",
70+
class: "myst-static-content",
71+
children: [{
72+
type: "code",
73+
language: "text",
74+
value: data.node.value,
75+
}],
76+
}],
77+
},
78+
{
79+
type: "div",
80+
class: "myst-static-output-wrapper",
81+
children: [{
82+
type: "div",
83+
class: "myst-static-content",
84+
children: data.body,
85+
}],
86+
},
87+
];
88+
},
89+
};
90+
5791
const plugin = {
58-
name: "Our custom functionality",
59-
doc: "Custom functionality for this workshop website",
60-
directives: [gitCommitDirective, youShouldNoticeDirective],
92+
name: 'Our custom functionality',
93+
doc: 'Custom functionality for this workshop website',
94+
directives: [gitCommitDirective, youShouldNoticeDirective, mystDemoStatic],
6195
}
6296
export default plugin;

0 commit comments

Comments
 (0)