Skip to content

Commit d9d5882

Browse files
committed
Get hyperrefs to work
1 parent 6c7aaa6 commit d9d5882

6 files changed

Lines changed: 13 additions & 8 deletions

File tree

04_data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ introduced earlier in the text.
3333

3434
ifdef::tex_target[]
3535

36-
The online coding sandbox for the book (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_)
36+
The online coding sandbox for the book (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])
3737
will automatically load the needed code when you are running a
3838
specific example. If you decide to work through the examples in
3939
another environment, be sure to start from the full code for this

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ book.pdf: tex/book/book.tex $(foreach CHAP,$(CHAPTERS),tex/$(CHAP).tex)
4242
pdfonce:
4343
cd tex/book && xelatex book.tex
4444
mv tex/book/book.pdf .
45+
46+
texclean:
47+
rm -f tex/book/book.aux tex/book/book.idx tex/book/book.log tex/book/book.out tex/book/book.tbc tex/book/book.toc

asciidoc_latex.conf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ subscript=_!..braceleft..!|!..braceright..!
3030
`=#monospaced
3131

3232
[link-inlinemacro]
33-
!..backslash..!hyperlink!..braceleft..!{target}!..braceright..!!..braceleft..!{0}!..braceright..!
33+
!..backslash..!hyperref[{target}]!..braceleft..!{0}!..braceright..!
3434

3535
[indexsee-inlinemacro]
3636
!..backslash..!index!..braceleft..!{1}|see!..braceleft..!{2}!..braceright..!!..braceright..!
3737

38+
[http-inlinemacro]
39+
!..backslash..!href!..braceleft..!http:{target}!..braceright..!!..braceleft..!{0}!..braceright..!
40+
3841
[blockdef-solution]
3942
delimiter=^!!solution!!$
4043
template=solution
@@ -52,9 +55,6 @@ source-style=template="codeblock"
5255
[texonly-inlinemacro]
5356
{text}
5457

55-
[http-inlinemacro]
56-
{0}
57-
5858
[image-blockmacro]
5959
\vskip 1.5ex
6060
\includegraphics[width={width=10cm}]\{{target}\}
@@ -94,6 +94,7 @@ template::[openblock]
9494

9595
[header]
9696
\chapter\{{doctitle}\}
97+
{docid?\label\{{docid}\}}
9798

9899
[sect1]
99100
\section\{{title}\}

bin/clean_latex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ process.stdin.on("data", function(chunk) {
1818
});
1919
process.stdin.on("end", function() {
2020
checkUnicode(input);
21-
input = input.replace(/(\n\n\\end{Code})|(\n{3,})|(_why,)|(\\chapter\{Introduction\})|\\hyperlink\{((?:[^{]|\\_\{\})+)\}/g, function(all, codeSpace, manyBlanks, why, intro, link) {
21+
input = input.replace(/(\n\n\\end{Code})|(\n{3,})|(_why,)|(\\chapter\{Introduction\})|\\hyperref\[((?:[^\]]|\\_\{\})+)\]/g, function(all, codeSpace, manyBlanks, why, intro, link) {
2222
if (codeSpace)
2323
return codeSpace.slice(1);
2424
if (manyBlanks)
@@ -28,7 +28,7 @@ process.stdin.on("end", function() {
2828
if (intro)
2929
return "\\chapter*{Introduction}";
3030
if (link)
31-
return "\\hyperlink{" + link.replace(/\\_\{\}/g, "_") + "}";
31+
return "\\hyperref[" + link.replace(/\\_\{\}/g, "_") + "]";
3232
});
3333
input = input.replace(/({\\hspace\*\{.+?\}\\itshape``)\s*([^]+?)\s*('')/g, "$1$2$3");
3434

bin/pre_latex.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ process.stdin.on("data", function(chunk) {
1111
input += chunk;
1212
});
1313
process.stdin.on("end", function() {
14+
var docid = /($|\n)\[\[(.*?)\]\]\n= /.exec(input);
15+
if (docid) input = ":docid: " + docid[2] + "\n" + input;
1416
process.stdout.write(input.replace(/\n===? (.*?) ===?|([.,:;])|\nimage::img\/(.+?)\.(svg)|link:[^\.]+\.html#(.*?)\[/g, function(match, title, quoted, imgName, imgType, link) {
1517
if (title) { // Section title, must be converted to title case
1618
var kind = /^\n(=*)/.exec(match)[1];

tex/book/book.tex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
\documentclass[cfonts]{nostarch}
2-
\usepackage{lipsum}
32
\usepackage{natbib}
43
\usepackage{nshyper}
54

0 commit comments

Comments
 (0)