Skip to content

Commit b4a6f75

Browse files
committed
Support inline if meta directives
1 parent 3fa81c6 commit b4a6f75

15 files changed

+41
-37
lines changed

01_values.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ number from them. Here is what they look like in JavaScript:
176176
100 + 4 * 11
177177
```
178178

179-
{{index [operator, application], asterisk, "plus character", "pass:[*] operator", "+ operator"}}
179+
{{index [operator, application], asterisk, "plus character", "* operator", "+ operator"}}
180180

181181
The `+` and `*`
182182
symbols are called _operators_. The first stands for addition, and the
@@ -406,7 +406,7 @@ possible to represent them as a sequence of numbers. When comparing
406406
strings, JavaScript goes over them from left to right, comparing the
407407
numeric codes of the characters one by one.
408408

409-
{{index equality, ">= operator", "pass:[<=] operator", "== operator", "!= operator"}}
409+
{{index equality, ">= operator", "<= operator", "== operator", "!= operator"}}
410410

411411
Other similar operators are `>=` (greater
412412
than or equal to), `<=` (less than or equal to), `==` (equal to), and
@@ -546,7 +546,7 @@ console.log(false == 0)
546546
// → true
547547
```
548548

549-
{{index "+ operator", arithmetic, "pass:[*] operator", "- operator"}}
549+
{{index "+ operator", arithmetic, "* operator", "- operator"}}
550550

551551
When an operator is applied to the “wrong” type of value,
552552
JavaScript will quietly convert that value to the type it wants, using

02_program_structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ exercises, refer to the [introduction](00_intro.html#intro).
940940

941941
Each exercise starts with a problem description. Read that and try to
942942
solve the exercise. If you run into problems, consider reading the
943-
hints (!interactive after the exercise!)(!book at the [end of the book](hints.html#hints)!).
943+
hints [after the exercise]{if interactive}[at the [end of the book](hints.html#hints)]{if book}.
944944
Full solutions to the exercises are not included in this
945945
book, but you can find them online at
946946
http://eloquentjavascript.net/code[_eloquentjavascript.net/code_].

03_functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ var landscape = function() {
208208
};
209209
210210
console.log(landscape());
211-
// → __/''''\_____/'\_
211+
// → ___/''''\______/'\_
212212
```
213213

214214
{{index [function, scope], scope}}

04_data.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ _ϕ_ can be computed using the following formula, where _n_ refers to the table:
520520

521521
{{if html
522522

523-
```{lang: null}
524523
<div>
525524
<style scoped="scoped">sub { font-size: 60%; }</style>
526525
<table style="border-collapse: collapse; margin-left: 1em;"><tr>
@@ -533,32 +532,31 @@ _ϕ_ can be computed using the following formula, where _n_ refers to the table:
533532
</td>
534533
</tr></table>
535534
</div>
536-
```
537535

538536
if}}
539537

540538
{{if tex
541539

542-
pass:[\begin{equation}\varphi = \frac{n_{11}n_{00}-n_{10}n_{01}}{\sqrt{n_{1\bullet}n_{0\bullet}n_{\bullet1}n_{\bullet0}}}\end{equation}]
540+
[\begin{equation}\varphi = \frac{n_{11}n_{00}-n_{10}n_{01}}{\sqrt{n_{1\bullet}n_{0\bullet}n_{\bullet1}n_{\bullet0}}}\end{equation}]{latex}
543541

544542
if}}
545543

546-
The notation (!html _n_~01~!)(!tex pass:[$n_{01}$]!) indicates the
544+
The notation [_n_~01~]{if html}[[$n_{01}$]{latex}]{if tex} indicates the
547545
number of measurements where the first variable (squirrelness) is false
548546
(0) and the second variable (pizza) is true (1). In this
549-
example, (!html _n_~01~!)(!tex pass:[$n_{01}$]!) is 9.
547+
example, [_n_~01~]{if html}[[$n_{01}$]{latex}]{if tex} is 9.
550548

551-
The value (!html _n_~1•~!)(!tex pass:[$n_{1\bullet}$]!) refers to the
549+
The value [_n_~1•~]{if html}[[$n_{1\bullet}$]{latex}]{if tex} refers to the
552550
sum of all measurements where the first variable is true, which is 5
553-
in the example table. Likewise, (!html _n_~•0~!)(!tex pass:[$n_{\bullet0}$]!)
551+
in the example table. Likewise, [_n_~•0~]{if html}[[$n_{\bullet0}$]{latex}]{if tex}
554552
refers to the sum of the measurements where the second variable is false.
555553

556554
{{index correlation, "phi coefficient"}}
557555

558556
So for the pizza table, the part
559557
above the division line (the dividend) would be 1×76 - 4×9 = 40, and
560558
the part below it (the divisor) would be the square root of
561-
5×85×10×80, or (!html √340000!)(!tex pass:[$\sqrt{340000}$]!). This
559+
5×85×10×80, or [√340000]{if html}[[$\sqrt{340000}$]{latex}]{if tex}. This
562560
comes out to _ϕ_ ≈ 0.069, which is tiny. Eating ((pizza)) does not
563561
appear to have influence on the transformations.
564562

@@ -605,15 +603,15 @@ This is simply a direct
605603
translation of the _ϕ_ formula into JavaScript. `Math.sqrt` is the
606604
square root function, as provided by the `Math` object in a standard
607605
JavaScript environment. We have to sum two fields from the table to
608-
get fields like (!html n~1•~!)(!tex pass:[$n_{1\bullet}$]!) because
606+
get fields like [n~1•~]{if html}[[$n_{1\bullet}$]{latex}]{if tex} because
609607
the sums of rows or columns are not stored directly in our data
610608
structure.
611609

612610
{{index "JOURNAL data set"}}
613611

614612
Jacques kept his journal for three months. The
615613
resulting ((data set)) is available in the coding sandbox for this
616-
chapter(!book (http://eloquentjavascript.net/code#4[_eloquentjavascript.net/code#4_])!),
614+
chapter[(http://eloquentjavascript.net/code#4[_eloquentjavascript.net/code#4_])]{if book},
617615
where it is stored in the `JOURNAL` variable, and in a downloadable
618616
http://eloquentjavascript.net/code/jacques_journal.js[file].
619617

05_higher_order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ console.log(JSON.parse(string).born);
475475
The variable `ANCESTRY_FILE`, available in
476476
the ((sandbox)) for this chapter and in
477477
http://eloquentjavascript.net/code/ancestry.js[a downloadable file] on
478-
the website(!book (http://eloquentjavascript.net/code#5[_eloquentjavascript.net/code#5_])!), contains the
478+
the website[(http://eloquentjavascript.net/code#5[_eloquentjavascript.net/code#5_])]{if book}, contains the
479479
content of my ((JSON)) file as a string. Let's decode it and see how
480480
many people it contains.
481481

06_object.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ The source data for the table of
813813
mountains that we are trying to build is available in the `MOUNTAINS`
814814
variable in the ((sandbox)) and also
815815
http://eloquentjavascript.net/code/mountains.js[downloadable] from the
816-
website(!book (http://eloquentjavascript.net/code#6[_eloquentjavascript.net/code#6_])!).
816+
website[(http://eloquentjavascript.net/code#6[_eloquentjavascript.net/code#6_])]{if book}.
817817

818818
{{index "table example"}}
819819

@@ -1188,7 +1188,7 @@ constructor can be done with the `Object.defineProperty` function. To
11881188
compute the distance from (0, 0) to (x, y), you can use the
11891189
Pythagorean theorem, which says that the square of the distance we are
11901190
looking for is equal to the square of the x-coordinate plus the square
1191-
of the y-coordinate. Thus, (!html √(x^2^ + y^2^pass:[)]!)(!tex pass:[$\sqrt{x^2 + y^2}$]!)
1191+
of the y-coordinate. Thus, [√(x^2^ + y^2^)]{if html}[[$\sqrt{x^2 + y^2}$]{latex}]{if tex}
11921192
is the number you want, and `Math.sqrt` is the way you compute a square
11931193
root in JavaScript.
11941194

07_elife.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ var valley = new LifelikeWorld(
10461046
{{index animation, simulation}}
10471047

10481048
Let's see what happens if we run this.
1049-
(!book These snapshots illustrate a typical run of this world.!)
1049+
[These snapshots illustrate a typical run of this world.]{if book}
10501050

10511051
{{if interactive
10521052

09_regexp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ console.log(/'\d*'/.test("''"));
236236
// → true
237237
```
238238

239-
{{index "pass:[*] operator", asterisk}}
239+
{{index "* operator", asterisk}}
240240

241241
The star (`*`) has a similar
242242
meaning but also allows the pattern to match zero times. Something

13_dom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ cells (`<td>`).
11141114
The same
11151115
source data that was used in [Chapter 6](06_object.html#mountains)
11161116
is again available in the `MOUNTAINS` variable in the sandbox. It can also be http://eloquentjavascript.net/code/mountains.js[downloaded]
1117-
from the website(!book (http://eloquentjavascript.net/code#13[_eloquentjavascript.net/code#13_])!).
1117+
from the website[(http://eloquentjavascript.net/code#13[_eloquentjavascript.net/code#13_])]{if book}.
11181118

11191119
Write a function `buildTable` that, given an array of objects that all
11201120
have the same set of properties, builds up a DOM structure

15_game.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ from the side, and do lots of jumping onto and over things.
3838

3939
Our
4040
((game)) will be roughly based on
41-
http://www.lessmilk.com/games/10[Dark Blue](!book (_www.lessmilk.com/games/10_)!) by Thomas Palef. I chose this game
41+
http://www.lessmilk.com/games/10[Dark Blue][ (_www.lessmilk.com/games/10_)]{if book} by Thomas Palef. I chose this game
4242
because it is both entertaining and minimalist, and because it can be built
4343
without too much ((code)). It looks like this:
4444

@@ -1269,8 +1269,8 @@ and output in general in [Chapter 20](20_node.html#node).
12691269
{{index game, "GAME_LEVELS data set"}}
12701270

12711271
There is a set of
1272-
((level)) plans available in the `GAME_LEVELS` variable (!book (downloadable from
1273-
http://eloquentjavascript.net/code#15[_eloquentjavascript.net/code#15_])!).
1272+
((level)) plans available in the `GAME_LEVELS` variable [(downloadable from
1273+
http://eloquentjavascript.net/code#15[_eloquentjavascript.net/code#15_])]{if book}.
12741274
This page feeds them to `runGame`, starting an actual game:
12751275

12761276
// start_code

0 commit comments

Comments
 (0)