Skip to content

Commit e88f86f

Browse files
committed
Stop including chapter numbers in text
Automatically resolve them when generating output instead
1 parent 86f4fec commit e88f86f

23 files changed

+263
-491
lines changed

00_intro.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ console.log(sum(range(1, 10)));
298298

299299
{{index readability}}
300300

301-
The moral of this story is that the same program can
302-
be expressed in long and short, unreadable and readable ways. The
303-
first version of the program was extremely obscure, whereas this last
304-
one is almost English: `log` the `sum` of the `range` of numbers from
305-
1 to 10. (We will see in [later chapters](04_data.html#data) how to
306-
build operations like `sum` and `range`.)
301+
The moral of this story is that the same program can be expressed in
302+
long and short, unreadable and readable ways. The first version of the
303+
program was extremely obscure, whereas this last one is almost
304+
English: `log` the `sum` of the `range` of numbers from 1 to 10. (We
305+
will see in [later chapters](data) how to build operations like `sum`
306+
and `range`.)
307307

308308
{{index ["programming language", "power of"], composability}}
309309

@@ -372,7 +372,7 @@ them out to you.
372372
This flexibility also
373373
has its advantages, though. It leaves space for a lot of techniques
374374
that are impossible in more rigid languages, and as you will see (for
375-
example in [Chapter 10](10_modules.html#modules)) it
375+
example in [Chapter ?](modules#modules)) it
376376
can be used to overcome some of JavaScript's shortcomings. After
377377
((learning)) the language properly and working with it for a while, I have
378378
learned to actually _like_ JavaScript.
@@ -399,7 +399,7 @@ Web browsers are not the only platforms on
399399
which JavaScript is used. Some databases, such as MongoDB and CouchDB,
400400
use JavaScript as their scripting and query language. Several
401401
platforms for desktop and server programming, most notably the
402-
((Node.js)) project (the subject of [Chapter 20](20_node.html#node)) are providing a powerful environment for programming JavaScript
402+
((Node.js)) project (the subject of [Chapter ?](node)) are providing a powerful environment for programming JavaScript
403403
outside of the browser.
404404

405405
## Code, and what to do with it
@@ -468,50 +468,47 @@ JavaScript in.
468468

469469
Throughout the book, there are five _project chapters_, which describe
470470
larger example programs to give you a taste of real programming. In
471-
order of appearance, we will work through building an
472-
[artificial life simulation](07_elife.html#elife), a
473-
[programming language](11_language.html#language), a
474-
[platform game](15_game.html#game), a
475-
[paint program](19_paint.html#paint), and a
476-
[dynamic website](21_skillsharing.html#skillsharing).
471+
order of appearance, we will work through building a [robot](robot), a
472+
[programming language](language), a [platform game](game), a [paint
473+
program](paint), and a [dynamic website](skillsharing).
477474

478475
The language part of the book starts with four chapters to introduce
479476
the basic structure of the JavaScript language. They introduce
480-
[control structures](02_program_structure.html#program_structure)
477+
[control structures](program_structure)
481478
(such as the `while` word you saw in this introduction),
482-
[functions](03_functions.html#functions) (writing your own
483-
operations), and [data structures](04_data.html#data). After these,
479+
[functions](functions) (writing your own
480+
operations), and [data structures](data). After these,
484481
you will be able to write simple programs. Next, Chapters
485-
[5](05_higher_order.html#higher_order) and
486-
[6](06_object.html#object) introduce techniques to use functions
482+
[5](higher_order) and
483+
[6](object) introduce techniques to use functions
487484
and objects to write more _abstract_ code and thus keep complexity
488485
under control.
489486

490-
After a [first project chapter](07_elife.html#elife), the first
487+
After a [first project chapter](robot), the first
491488
part of the book continues with chapters on
492-
[error handling and fixing](08_error.html#error), on
493-
[regular expressions](09_regexp.html#regexp) (an important tool for
489+
[error handling and fixing](error), on
490+
[regular expressions](regexp) (an important tool for
494491
working with text data), and on
495-
[modularity](10_modules.html#modules)—another weapon against
496-
complexity. The [second project chapter](11_language.html#language)
492+
[modularity](modules)—another weapon against
493+
complexity. The [second project chapter](language)
497494
concludes the first part of the book.
498495

499-
The second part, Chapters [12](12_browser.html#browser) to
500-
[19](19_paint.html#paint), describes the tools that browser
496+
The second part, Chapters [?](browser) to
497+
[?](paint), describes the tools that browser
501498
JavaScript has access to. You'll learn to display things on the screen
502-
(Chapters [13](13_dom.html#dom) and
503-
[16](16_canvas.html#canvas)), respond to user input (Chapters
504-
[14](14_event.html#event) and [18](18_forms.html#forms)), and
505-
communicate over the network ([Chapter 17](17_http.html#http)).
499+
(Chapters [?](dom) and
500+
[?](canvas)), respond to user input (Chapters
501+
[?](event) and [?](forms)), and
502+
communicate over the network ([Chapter ?](http)).
506503
There are again two project chapters in this part.
507504

508-
After that, [Chapter 20](20_node.html#node) describes Node.js, and
509-
[Chapter 21](21_skillsharing.html#skillsharing) builds a simple web
505+
After that, [Chapter ?](node) describes Node.js, and
506+
[Chapter ?](skillsharing) builds a simple web
510507
system using that tool.
511508

512509
{{if commercial
513510

514-
Finally, [Chapter 22](22_fast.html#fast) describes some of the
511+
Finally, [Chapter ?](fast) describes some of the
515512
considerations that come up when optimizing JavaScript programs for
516513
speed.
517514

01_values.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ produce the string `"concatenate"`:
319319
```
320320

321321
Strings also have a number of associated functions (_methods_) which
322-
we will come back to in [Chapter 4](04_data.html#methods).
322+
we will come back to in [Chapter ?](data#methods).
323323

324324
{{{index interpolation, backtick}}}
325325

@@ -358,7 +358,7 @@ console.log(typeof "x")
358358

359359
We will use `console.log` in example code to indicate that we want to
360360
see the result of evaluating something. More about that in the [next
361-
chapter](02_program_structure.html).
361+
chapter](program_structure).
362362

363363
{{index negation, "- operator", "binary operator", "unary operator"}}
364364

@@ -677,5 +677,5 @@ logically, and `typeof` to find a value's type) and a ternary operator
677677

678678
This gives you enough information to use JavaScript as a pocket
679679
calculator, but not much more. The [next
680-
chapter](02_program_structure.html#program_structure) will start tying
680+
chapter](program_structure) will start tying
681681
these expressions together into basic programs.

02_program_structure.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ the point where we can express meaningful prose.
2222

2323
{{index grammar, syntax, [code, "structure of"], grammar, [JavaScript, syntax]}}
2424

25-
In [Chapter 1](01_values.html#values), we made some values and applied
25+
In [Chapter ?](values), we made some values and applied
2626
operators to them to get new values. Creating values like this is the
2727
main substance of any JavaScript program. But that substance has to be
2828
framed in a larger structure to be useful. So that's what we'll get to
@@ -186,7 +186,7 @@ console.log(greeting + name);
186186

187187
The first, `var` (short for "variable"), is the way bindings were
188188
declared in pre-2015 JavaScript. We'll get back to the precise way it
189-
differs from `let` in the [next chapter](03_functions.html). For now,
189+
differs from `let` in the [next chapter](functions). For now,
190190
remember that it mostly does the same thing, but we'll rarely use it
191191
in this book because it has some confusing properties.
192192

@@ -309,7 +309,7 @@ Though binding names cannot contain ((period character))s,
309309
simple binding. It is actually an expression that retrieves the `log`
310310
((property)) from the value held by the `console` binding. We will
311311
find out exactly what this means in [Chapter
312-
4](04_data.html#properties).
312+
?](data#properties).
313313

314314
{{id return_values}}
315315
## Return values
@@ -341,8 +341,8 @@ console.log(Math.min(2, 4) + 100);
341341
// → 102
342342
```
343343

344-
The [next chapter](03_functions.html#functions) explains how to
345-
write your own functions.
344+
The [next chapter](functions) explains how to write your own
345+
functions.
346346

347347
## Control flow
348348

@@ -551,7 +551,7 @@ console.log(result);
551551

552552
The counter could also have started at `1` and checked for `<= 10`,
553553
but, for reasons that will become apparent in [Chapter
554-
4](04_data.html#array_indexing), it is a good idea to get used to
554+
?](data#array_indexing), it is a good idea to get used to
555555
counting from 0.
556556

557557
{{index "loop body", "do loop", "control flow"}}
@@ -639,7 +639,7 @@ for (let number = 0; number <= 12; number = number + 2) {
639639
{{index "control flow", state}}
640640

641641
This program is exactly equivalent to the
642-
[earlier](02_program_structure.html#loops) even-number-printing
642+
[earlier](program_structure#loops) even-number-printing
643643
example. The only change is that all the ((statement))s that are
644644
related to the “state” of the loop are now grouped together.
645645

@@ -835,7 +835,7 @@ mixed naming styles can be jarring to read, so we follow this
835835
In a few cases, such as the `Number` function, the first letter of a
836836
binding is also capitalized. This was done to mark this function as a
837837
constructor. What a constructor is will become clear in [Chapter
838-
6](06_object.html#constructors). For now, the important thing is not
838+
?](object#constructors). For now, the important thing is not
839839
to be bothered by this apparent lack of ((consistency)).
840840

841841
## Comments
@@ -910,7 +910,7 @@ a function call is an expression, and may produce a value.
910910
{{index exercises}}
911911

912912
If you are unsure how to try your solutions to exercises, refer to the
913-
[introduction](00_intro.html#intro).
913+
[introduction](intro).
914914

915915
Each exercise starts with a problem description. Read that and try to
916916
solve the exercise. If you run into problems, consider reading the
@@ -966,7 +966,7 @@ if}}
966966

967967
You can start with a program that simply prints out the numbers 1 to
968968
7, which you can derive by making a few modifications to the [even
969-
number printing example](02_program_structure.html#loops) given
969+
number printing example](program_structure#loops) given
970970
earlier in the chapter, where the `for` loop was introduced.
971971

972972
Now consider the equivalence between numbers and strings of hash

03_functions.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ if (safeMode) {
250250

251251
{{index [function, "higher-order"]}}
252252

253-
In [Chapter 5](05_higher_order.html#higher_order), we will discuss the
254-
wonderful things that can be done by passing around function values to
255-
other functions.
253+
In [Chapter ?](higher_order), we will discuss the wonderful things
254+
that can be done by passing around function values to other functions.
256255

257256
## Declaration notation
258257

@@ -344,7 +343,7 @@ const horn = () => {
344343
Arrow functions are a relatively recent addition to the language, and
345344
their main use is to allow simple function expressions to be less
346345
verbose. We'll be using a lot of them in [Chapter
347-
5](05_higher_order.html).
346+
?](higher_order).
348347

349348
{{id stack}}
350349
## The call stack
@@ -493,7 +492,7 @@ console.log(power(2, 6));
493492

494493
{{index "console.log"}}
495494

496-
In the [next chapter](04_data.html#rest_parameters), we will see a way
495+
In the [next chapter](data#rest_parameters), we will see a way
497496
in which a function body can get at the whole list of arguments it was
498497
passed. This is helpful because it makes it possible for a function to
499498
accept any number of arguments. For example, `console.log` makes use
@@ -620,7 +619,7 @@ machine-friendliness. Almost any program can be made faster by making
620619
it bigger and more convoluted. The programmer must decide on an
621620
appropriate balance.
622621

623-
In the case of the [earlier](03_functions.html#power) `power`
622+
In the case of the [earlier](functions#power) `power`
624623
function, the inelegant (looping) version is still fairly simple and
625624
easy to read. It doesn't make much sense to replace it with the
626625
recursive version. Often, though, a program deals with such complex
@@ -970,7 +969,7 @@ the way that chapters and sections help organize a text.
970969

971970
{{index "Math object", "minimum (exercise)", "Math.min function", minimum}}
972971

973-
The [previous chapter](02_program_structure.html#return_values)
972+
The [previous chapter](program_structure#return_values)
974973
introduced the standard function `Math.min` that returns its smallest
975974
argument. We can do that ourselves now. Write a function `min` that
976975
takes two arguments and returns their minimum.
@@ -1046,7 +1045,7 @@ if}}
10461045

10471046
Your function will likely look somewhat similar to the inner `find`
10481047
function in the recursive `findSolution`
1049-
[example](03_functions.html#recursive_puzzle) in this chapter, with an
1048+
[example](functions#recursive_puzzle) in this chapter, with an
10501049
`if`/`else if`/`else` chain that tests which of the three cases
10511050
applies. The final `else`, corresponding to the third case, makes the
10521051
recursive call. Each of the branches should contain a `return`

04_data.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ uppercase. There is also `toLowerCase`, going the other way.
208208
Interestingly, even though the call to `toUpperCase` does not pass any
209209
arguments, the function somehow has access to the string `"Doh"`, the
210210
value whose property we called. How this works is described in
211-
[Chapter 6](06_object.html#obj_methods).
211+
[Chapter ?](object#obj_methods).
212212

213213
Properties that contain functions are generally called _methods_ of
214214
the value they belong to. As in, “_toUpperCase_ is a method of a
@@ -242,7 +242,7 @@ a _((stack))_. A stack, in programming, is a ((data structure)) that
242242
allows you to push values into it and pop them out again in the
243243
opposite order—the thing that was added last is removed first. These
244244
are common in programming—you might remember the function ((call
245-
stack)) from [the previous chapter](03_functions.html#stack), which is
245+
stack)) from [the previous chapter](functions#stack), which is
246246
an instance of the same idea.
247247

248248
## Objects
@@ -445,9 +445,8 @@ only if both objects are precisely the same value. Comparing different
445445
objects will return `false`, even if they have identical contents.
446446
There is no “deep” comparison operation built into JavaScript, which
447447
looks at object's contents, but it is possible to write it yourself
448-
(which will be one of the
449-
[exercises](04_data.html#exercise_deep_compare) at the end of this
450-
chapter).
448+
(which will be one of the [exercises](data#exercise_deep_compare) at
449+
the end of this chapter).
451450

452451
## The lycanthrope's log
453452

@@ -696,7 +695,7 @@ When a `for` loops looks like this, with the word `of` after a
696695
variable definition, it will loop over the elements of the value given
697696
after `of`. This works not only for arrays, but also for strings and
698697
some other data structures. We'll discuss _how_ it works in [Chapter
699-
6](06_object.html).
698+
?](object).
700699

701700
{{id analysis}}
702701

@@ -814,7 +813,7 @@ generally useful array methods.
814813
{{index "push method", "pop method", "shift method", "unshift method"}}
815814

816815
We saw `push` and `pop`, which add and remove elements at the
817-
end of an array, [earlier](04_data.html#array_methods) in this
816+
end of an array, [earlier](data#array_methods) in this
818817
chapter. The corresponding methods for adding and removing things at
819818
the start of an array are called `unshift` and `shift`.
820819

@@ -952,7 +951,7 @@ console.log(" okay \n ".trim());
952951
We have already seen the string type's `length` property. Accessing
953952
the individual characters in a string looks like accessing array
954953
elements (with a caveat that we'll discuss in [Chapter
955-
5](05_higher_order.html#code_units)).
954+
?](higher_order#code_units)).
956955

957956
```
958957
let string = "abc";
@@ -1075,7 +1074,7 @@ console.log(randomPointOnCircle(2));
10751074

10761075
If sines and cosines are not something you are very familiar with,
10771076
don't worry. When they are used in this book, in [Chapter
1078-
13](13_dom.html#sin_cos), I'll explain them.
1077+
?](dom#sin_cos), I'll explain them.
10791078

10801079
{{index "Math.random function", "random number"}}
10811080

@@ -1268,8 +1267,8 @@ You can iterate over arrays using a special kind of `for` loop—`for
12681267

12691268
{{index "summing (exercise)"}}
12701269

1271-
The [introduction](00_intro.html) of this book alluded to the
1272-
following as a nice way to compute the sum of a range of numbers:
1270+
The [introduction](intro) of this book alluded to the following as a
1271+
nice way to compute the sum of a range of numbers:
12731272

12741273
```{test: no}
12751274
console.log(sum(range(1, 10)));
@@ -1359,7 +1358,7 @@ Neither may use the standard `reverse` method.
13591358
{{index efficiency, "pure function", "side effect"}}
13601359

13611360
Thinking back to the notes about side effects and pure functions in
1362-
the [previous chapter](03_functions.html#pure), which variant do you
1361+
the [previous chapter](functions#pure), which variant do you
13631362
expect to be useful in more situations? Which one is more efficient?
13641363

13651364
{{if interactive

05_higher_order.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ order to process data, we'll need some data. This chapter will use a
281281
((data set)) about ((writing system))s—such as Latin, Cyrillic, and
282282
Arabic.
283283

284-
Remember ((Unicode)) from [Chapter 1](01_values.html#unicode), the
284+
Remember ((Unicode)) from [Chapter ?](values#unicode), the
285285
system that assigns a number to each character in written language.
286286
Most of these characters are associated with a script. The standard
287287
contains 140 different scripts. 81 of those are still in use today.
@@ -609,7 +609,7 @@ the elements in the array.
609609

610610
But how do we get the character codes in a string?
611611

612-
In [Chapter 1](01_values.html) I mentioned that JavaScript ((string))s
612+
In [Chapter ?](values) I mentioned that JavaScript ((string))s
613613
are encoded as a sequence of 16-bit number called _((code unit))s_. A
614614
((Unicode)) ((character)) code was initially supposed to fit within
615615
such a unit (which gives you a little over 65 thousand characters).
@@ -662,7 +662,7 @@ charcter takes up one or two code units.
662662

663663
{{index "for/of loop", character}}
664664

665-
In the [previous chapter](04_data.html#for_of_loop), I mentioned that
665+
In the [previous chapter](data#for_of_loop), I mentioned that
666666
a `for`/`of` loop can also be used on strings. Like `codePointAt`,
667667
this type of loop was introduced at a time where people were acutely
668668
aware of the problems with UTF-16. And when you use it to loop over a

0 commit comments

Comments
 (0)