@@ -19,14 +19,21 @@ You can enable including non-explicit `.md` inputs by passing the `--enable-mark
19
19
20
20
You can pass local ` .md ` inputs by passing their path to Scala CLI (as you would for any other kind of input).
21
21
22
- ``` bash ignore
23
- scala-cli hello.md
22
+ ```` markdown title=dir/hello.md
23
+ # Simple snippet
24
+ ```scala
25
+ println("Hello")
26
+ ```
27
+ ````
28
+
29
+ ``` bash
30
+ scala-cli dir/hello.md
24
31
```
25
32
26
33
` .md ` sources inside of directories are ignored by default, unless the ` --enable-markdown ` option is passed.
27
34
28
- ``` bash ignore
29
- scala-cli dir-with-markdown --enable-markdown
35
+ ``` bash
36
+ scala-cli dir --enable-markdown
30
37
```
31
38
32
39
### Zipped archives
@@ -147,7 +154,7 @@ top-level.
147
154
148
155
<ChainedSnippets >
149
156
150
- ``` bash ignore
157
+ ``` bash
151
158
scala-cli run Example.md
152
159
```
153
160
@@ -160,14 +167,29 @@ Hello from Markdown
160
167
Similarly to ` .sc ` scripts, when multiple ` .md ` files with plain ` scala ` snippets are being run, each of them will have
161
168
its own main class, that can be run.
162
169
170
+ ```` markdown title=Main1.md
171
+ # Main class 1
172
+ ```scala
173
+ println("1")
174
+ ```
175
+ ````
176
+
177
+
178
+ ```` markdown title=Main2.md
179
+ # Main class 2
180
+ ```scala
181
+ println("2")
182
+ ```
183
+ ````
184
+
163
185
<ChainedSnippets >
164
186
165
- ``` bash ignore
166
- scala-cli Example1 .md Example2 .md
187
+ ``` bash fail
188
+ scala-cli Main1 .md Main2 .md
167
189
```
168
190
169
191
``` text
170
- [error] Found several main classes: Example1_md, Example2_md
192
+ [error] Found several main classes: Main1_md, Main2_md
171
193
```
172
194
173
195
</ChainedSnippets >
@@ -177,12 +199,12 @@ option.
177
199
178
200
<ChainedSnippets >
179
201
180
- ``` bash ignore
181
- scala-cli Example1 .md Example2 .md --main-class Example1_md
202
+ ``` bash
203
+ scala-cli Main1 .md Main2 .md --main-class Main1_md
182
204
```
183
205
184
206
``` text
185
- Hello from Markdown
207
+ 1
186
208
```
187
209
188
210
</ChainedSnippets >
@@ -191,12 +213,12 @@ You can always check what main classes are available in the context with the `--
191
213
192
214
<ChainedSnippets >
193
215
194
- ``` bash ignore
195
- scala-cli Example1 .md Example2 .md --list-main-classes
216
+ ``` bash
217
+ scala-cli Main1 .md Main2 .md --list-main-classes
196
218
```
197
219
198
220
``` text
199
- Example1_md Example2_md
221
+ Main1_md Main2_md
200
222
```
201
223
202
224
</ChainedSnippets >
@@ -222,7 +244,7 @@ object Main extends App {
222
244
223
245
<ChainedSnippets >
224
246
225
- ``` bash ignore
247
+ ``` bash
226
248
scala-cli RawExample.md
227
249
```
228
250
@@ -255,7 +277,7 @@ class Test extends munit.FunSuite {
255
277
256
278
<ChainedSnippets >
257
279
258
- ``` bash ignore
280
+ ``` bash
259
281
scala-cli test TestExample.md
260
282
```
261
283
@@ -303,8 +325,8 @@ println(message)
303
325
304
326
<ChainedSnippets >
305
327
306
- ``` bash ignore
307
- scala-cli test ResetExample.md
328
+ ``` bash
329
+ scala-cli ResetExample.md
308
330
```
309
331
310
332
``` text
@@ -315,12 +337,12 @@ world
315
337
316
338
</ChainedSnippets >
317
339
318
- ## ` using ` directives and markdown code blocks
340
+ ## ` using ` directives and Markdown code blocks
319
341
320
342
It is possible to define ` using ` directives at the beginning of a ` scala ` code block inside a markdown input.
321
343
This is supported for all ` scala ` code block flavours.
322
344
323
- ```` markdown title=UsingDirectives.md
345
+ ```` markdown compile title=UsingDirectives.md
324
346
# Using directives in `.md` inputs
325
347
326
348
## `scala raw` example
@@ -339,7 +361,7 @@ println(os.pwd)
339
361
340
362
## `scala test` example
341
363
```scala test
342
- //> using lib "org.scalameta::munit:0.7.29 "
364
+ //> using lib "org.scalameta::munit:1.0.0-M7 "
343
365
344
366
class Test extends munit.FunSuite {
345
367
test("foo") {
@@ -362,7 +384,7 @@ pprint.pprintln("world")
362
384
` scala ` snippets inside of a Markdown input are not isolated. Each ` using ` directive applies to the whole project's
363
385
context. A directive defined in a later snippet within the same source may override another defined in an earlier one.
364
386
365
- ```` markdown title=" OverriddenDirective.md"
387
+ ```` markdown title=OverriddenDirective.md
366
388
## 1
367
389
368
390
```scala
@@ -383,7 +405,7 @@ be used for both.
383
405
384
406
<ChainedSnippets >
385
407
386
- ``` bash ignore
408
+ ``` bash
387
409
scala-cli OverriddenDirective.md
388
410
```
389
411
@@ -411,35 +433,35 @@ snippet): `Scope{scopeNumber}`. The `snippetNumber` is omitted for the first scr
411
433
the first scope is just ` Scope ` , the second is ` Scope1 ` , then ` Scope2 ` and so on.
412
434
413
435
```` markdown title=src/markdown/Example.md
414
- ## Scope 1
436
+ ## Scope 0
415
437
```scala
416
438
def hello: String = "Hello"
417
439
```
418
440
419
- ## Still scope 1 , since `reset` wasn't used yet
441
+ ## Still scope 0 , since `reset` wasn't used yet
420
442
```scala
421
443
def space: String = " "
422
444
```
423
445
424
- ## Scope 2
446
+ ## Scope 1
425
447
```scala reset
426
448
def world: String = "world"
427
449
```
428
450
````
429
451
430
452
``` scala title=Main.scala
431
453
object Main extends App {
432
- val hello = src. markdown.Example_md .Scope .hello
433
- val space = src. markdown.Example_md .Scope .space
434
- val world = src. markdown.Example_md .Scope .world
435
- println(s " $hello$space$world)
454
+ val hello = markdown.Example_md .Scope .hello
455
+ val space = markdown.Example_md .Scope .space
456
+ val world = markdown.Example_md .Scope1 .world
457
+ println(s " $hello$space$world" )
436
458
}
437
459
```
438
460
439
461
<ChainedSnippets >
440
462
441
- ```bash ignore
442
- scala-cli . --enable-markdown --main-class Main
463
+ ``` bash
464
+ scala-cli src Main.scala --enable-markdown --main-class Main
443
465
```
444
466
445
467
``` text
@@ -463,7 +485,7 @@ object Something {
463
485
464
486
<ChainedSnippets >
465
487
466
- ```bash ignore
488
+ ``` bash
467
489
scala-cli RawSnippetToReferTo.md -e ' println(Something.message)'
468
490
```
469
491
0 commit comments