You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/markdown-options.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,6 +184,39 @@ For values, the following options are available:
184
184
-`hasValue`: if set, the content will be shown if the variable has any value
185
185
-`hasNoValue`: if set, the content will be shown if the variable is undefined or empty
186
186
187
+
### OS-conditional displays
188
+
189
+
The `:::conditionalDisplay` directive also supports filtering by the operating system of the user's browser using the `os` parameter. This is useful when commands must run natively on the user's machine and differ between platforms.
190
+
191
+
Example:
192
+
193
+
:::conditionalDisplay{os="unix"}
194
+
On Mac/Linux, run:
195
+
196
+
```bash
197
+
echo "Hello from a Unix-like shell"
198
+
```
199
+
:::
200
+
201
+
:::conditionalDisplay{os="windows"}
202
+
On Windows, run:
203
+
204
+
```powershell
205
+
Write-Host "Hello from PowerShell"
206
+
```
207
+
:::
208
+
209
+
Supported `os` values (comma-separated for multiple):
210
+
211
+
-`mac` — macOS
212
+
-`linux` — Linux
213
+
-`windows` — Windows
214
+
-`unix` — alias for `mac,linux`
215
+
216
+
The `os` parameter can be combined with `variable`, `requiredValue`, `hasValue`, or `hasNoValue`. When both are present, the content is shown only if *both* the OS and variable conditions match.
217
+
218
+
OS detection uses `navigator.userAgentData.platform` when available, falling back to `navigator.platform`. Detection happens in the user's browser, so the result reflects where the browser is running — which is what matters for commands meant to run natively on the user's machine.
219
+
187
220
### Labspace-defined variables
188
221
189
222
To support easier maintenance for values that may need to be updated in multiple locations, variables can also be defined in the `labspace.yaml` file.
Copy file name to clipboardExpand all lines: sample-content-repo/labspace/04-variables.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,26 @@ Variables can be used to support the conditional displaying of text.
58
58
> It appears the conditional is set and this content is displayed!
59
59
:::
60
60
61
+
## OS-conditional display
62
+
63
+
Content can also be filtered by the operating system the user is viewing from. This is useful for showing commands that run natively on the user's machine.
64
+
65
+
:::conditionalDisplay{os="unix"}
66
+
You appear to be on Mac or Linux. Try this:
67
+
68
+
```bash
69
+
echo"Hello from a Unix-like shell"
70
+
```
71
+
:::
72
+
73
+
:::conditionalDisplay{os="windows"}
74
+
You appear to be on Windows. Try this:
75
+
76
+
```powershell
77
+
Write-Host "Hello from PowerShell"
78
+
```
79
+
:::
80
+
61
81
## Default Labspace variables
62
82
63
83
As a help to authors, variables can also be defined in the `labspace.yaml` file to reduce maintenance where a value may appear in multiple places throughout the writeup.
0 commit comments