helpers
This commit is contained in:
parent
f0b976cea1
commit
7a6abff9f9
@ -175,9 +175,7 @@ func main() {
|
|||||||
panic("Wrong number of args")
|
panic("Wrong number of args")
|
||||||
}
|
}
|
||||||
outF, err := os.Create(os.Args[1])
|
outF, err := os.Create(os.Args[1])
|
||||||
if err != nil {
|
check(err)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
ensureCache()
|
ensureCache()
|
||||||
fmt.Fprint(outF,
|
fmt.Fprint(outF,
|
||||||
`<!DOCTYPE html>
|
`<!DOCTYPE html>
|
||||||
@ -190,9 +188,7 @@ func main() {
|
|||||||
<body>`)
|
<body>`)
|
||||||
|
|
||||||
indexBytes, err := ioutil.ReadFile("src/index.txt")
|
indexBytes, err := ioutil.ReadFile("src/index.txt")
|
||||||
if err != nil {
|
check(err)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
indexLines := strings.Split(string(indexBytes), "\n")
|
indexLines := strings.Split(string(indexBytes), "\n")
|
||||||
indexNames := make([]string, 0)
|
indexNames := make([]string, 0)
|
||||||
for _, indexLine := range indexLines {
|
for _, indexLine := range indexLines {
|
||||||
@ -206,13 +202,9 @@ func main() {
|
|||||||
if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") {
|
if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") {
|
||||||
sourcePath := "src/" + indexName + "/" + indexName + ".html"
|
sourcePath := "src/" + indexName + "/" + indexName + ".html"
|
||||||
sourceBytes, err := ioutil.ReadFile(sourcePath)
|
sourceBytes, err := ioutil.ReadFile(sourcePath)
|
||||||
if err != nil {
|
check(err)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
_, err = outF.Write(sourceBytes)
|
_, err = outF.Write(sourceBytes)
|
||||||
if err != nil {
|
check(err)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
chapterPath := "src/" + indexName
|
chapterPath := "src/" + indexName
|
||||||
fmt.Fprintf(outF,
|
fmt.Fprintf(outF,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user