diff --git a/src/book.css b/src/book.css index 0a1223d..497ef8b 100644 --- a/src/book.css +++ b/src/book.css @@ -31,8 +31,19 @@ hr { height: 1px; margin: 16px 0; } -table { +div.chapter { page-break-inside: avoid; +} +div#title { + page-break-after: always; +} +div#contents { + page-break-after: always; +} +div#introduction { + page-break-after: always; +} +table { width: 690px; min-width: 690px; max-width: 690px; diff --git a/src/index.txt b/src/contents.txt similarity index 96% rename from src/index.txt rename to src/contents.txt index 83b8dc8..88aeb61 100644 --- a/src/index.txt +++ b/src/contents.txt @@ -1,7 +1,4 @@ -title -contents introduction - hello-world values variables @@ -29,7 +26,6 @@ embedding interfaces errors ok-guards - goroutines concurrent-goroutines channels @@ -47,7 +43,6 @@ timers tickers state-goroutine state-mutex - sorting sorting-by-functions collection-functions @@ -64,7 +59,6 @@ number-parsing urls sha1-hashes base64-encoding - reading-files writing-files line-filters @@ -75,12 +69,10 @@ spawning-processes execing-processes signals exit - http-client https-client redis postgres - hello-web responses request-routing @@ -90,4 +82,4 @@ basic-authentication canonical-hosts middleware graceful-shutdown -https-servers +https-servers \ No newline at end of file diff --git a/src/contents/contents.html b/src/contents/contents.html deleted file mode 100644 index 6a46643..0000000 --- a/src/contents/contents.html +++ /dev/null @@ -1,7 +0,0 @@ -

Contents

- - diff --git a/src/introduction/introduction.html b/src/introduction.html similarity index 92% rename from src/introduction/introduction.html rename to src/introduction.html index 12eb89f..adc2705 100644 --- a/src/introduction/introduction.html +++ b/src/introduction.html @@ -1,5 +1,5 @@

Introduction

- +

Why you should care.

- +

This is why.

diff --git a/src/scatter-gather/081-scatter-gather.go b/src/scatter-gather/scatter-gather.go similarity index 100% rename from src/scatter-gather/081-scatter-gather.go rename to src/scatter-gather/scatter-gather.go diff --git a/src/title.html b/src/title.html new file mode 100644 index 0000000..b4d50de --- /dev/null +++ b/src/title.html @@ -0,0 +1,7 @@ +
+

Go by Example

+ +

Mark McGranaghan

+ +

Version eb9cf61d

+
diff --git a/src/title/title.html b/src/title/title.html deleted file mode 100644 index f759930..0000000 --- a/src/title/title.html +++ /dev/null @@ -1,5 +0,0 @@ -

Go by Example

- -

Mark McGranaghan

- -

Version eb9cf61d

diff --git a/tool/build-html.go b/tool/build-html.go index 4a669db..9331e1c 100644 --- a/tool/build-html.go +++ b/tool/build-html.go @@ -186,6 +186,8 @@ func main() { outF, err := os.Create(os.Args[1]) check(err) ensureCache() + + // Header fmt.Fprint(outF, ` @@ -196,20 +198,31 @@ func main() { `) - indexLines := readLines("src/index.txt") - indexNames := filterStrings(indexLines, func(s string) bool { - return s != "" - }) + // Title page + fmt.Fprint(outF, mustReadFile("src/title.html")) - for _, indexName := range indexNames { - fmt.Fprintf(outF, `
`, indexName) - if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") { - sourcePath := "src/" + indexName + "/" + indexName + ".html" - source := mustReadFile(sourcePath) - _, err = outF.WriteString(source) - check(err) + // Contents page + chapterIds := readLines("src/contents.txt") + fmt.Fprint(outF, `

Contents

`) + + // Content chapters + for _, chapterId := range chapterIds { + fmt.Fprintf(outF, `
`, chapterId) + if chapterId == "introduction" { + fmt.Fprint(outF, mustReadFile("src/introduction.html")) + } else { + chapterPath := "src/" + chapterId fmt.Fprintf(outF, ``, chapterPath) @@ -235,5 +248,7 @@ func main() { } fmt.Fprintf(outF, ``) } + + // Footer fmt.Fprint(outF, ``) }