Skip to content

Commit 1cae9a2

Browse files
committed
Include code that runs the chapter's project when selecting a chapter in code sandbox
Closes marijnh#89
1 parent 9091f1a commit 1cae9a2

File tree

13 files changed

+68
-17
lines changed

13 files changed

+68
-17
lines changed

04_data.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ squirrel-lycanthropy. It _does_ seem to occur somewhat more often on
730730
weekends, however. Let's filter the results to show only correlations
731731
greater than 0.1 or less than -0.1.
732732

733+
// start_code
733734
// test: no
734735

735736
[source,javascript]

05_higher_order.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,9 @@ We can then use this to compute the amount of ((DNA)) my
788788
((grandfather)) shared with Pauwels van Haverbeke, and divide that by
789789
four.
790790

791+
// start_code bottom_lines: 2
791792
// test: clip
793+
// include_code top_lines: 6
792794

793795
[source,javascript]
794796
----

06_object.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ them to our new prototype.
956956
function to use `RTextCell`'s for cells whose value is a number, we
957957
get the table we were aiming for:
958958

959+
// start_code bottom_lines: 1
959960
// include_code strip_log
960961

961962
[source,javascript]

07_elife.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ var valley = new LifelikeWorld(
10201020

10211021
ifdef::html_target[]
10221022

1023+
// start_code
10231024
// test: no
10241025

10251026
[source,javascript]

11_language.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ The function created by the `fun` form creates this local environment,
551551
and adds the argument variables to it. It then evaluates the function
552552
body in this environment, and returns the result.
553553

554+
// start_code
555+
554556
[source,javascript]
555557
----
556558
run("do(define(plusOne, fun(a, +(a, 1))),",

15_game.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,8 @@ There is a set of level plans available in the `GAME_LEVELS` variable
11521152
http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])!).
11531153
This page feeds them to `runGame`, starting an actual game:
11541154

1155+
// start_code
1156+
11551157
[sandbox="null"]
11561158
[focus="yes"]
11571159
[source,text/html]

16_canvas.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,8 @@ ifdef::html_target[]
10411041

10421042
The tiny document below plugs the new display into `runGame`:
10431043

1044+
// start_code
1045+
10441046
[sandbox="game"]
10451047
[focus="yes"]
10461048
[source,text/html]

18_forms.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ because only strings can be stored there. The user can select a note
605605
from a `<select>` field, and change that note's text in a
606606
`<textarea>`. A note can be added by pressing a button.
607607

608+
// start_code
609+
608610
[source,text/html]
609611
----
610612
Notes: <select id="list"></select>

19_paint.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ try it out.!)
623623

624624
ifdef::html_target[]
625625

626+
// start_code
627+
626628
[sandbox="paint"]
627629
[source,text/html]
628630
----

bin/build_code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var fs = require("fs");
33
var file = process.argv[2];
44
var input = fs.readFileSync(file, "utf8");
55

6-
var included = /\/\/ include_code(.*)\n(?:\/\/.*\n)*\s*(?:\[sandbox=.*\n|\[\[.*\n)*\[source,.*?\]\n----\n([\s\S]*?\n)----/g, m;
6+
var included = /\/\/ include_code(.*)\n(?:\/\/.*\n)*\s*(?:\[.*\n)*\[source,.*?\]\n----\n([\s\S]*?\n)----/g, m;
77
var files = Object.create(null);
88
var defaultFile = "code/chapter/" + file.replace(".txt", ".js");
99

0 commit comments

Comments
 (0)