add title

This commit is contained in:
Mark McGranaghan
2012-09-29 14:06:57 -07:00
parent f57c28f42c
commit dbf69907cc
2 changed files with 15 additions and 7 deletions

View File

@@ -17,6 +17,9 @@ import (
// Recognize doc lines, extract their comment prefixes.
var docsPat = regexp.MustCompile("^\\s*\\/\\/\\s")
// Recognize title prefixes, for titling web page.
var titlePat = regexp.MustCompile("^\\/\\/\\s##\\s")
// Abort on non-nil errors.
func check(err error) {
if err != nil {
@@ -108,12 +111,12 @@ func main() {
}
// Print HTML header.
fmt.Print(`
fmt.Printf(`
<!DOCTYPE html>
<html>
<head>
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
<title>Page Title</title>
<title>%s</title>
<link rel=stylesheet href="book.css">
</head>
<body>
@@ -123,7 +126,7 @@ func main() {
<thead>
<tr><td class=docs></td><td class=code></td></tr>
</thead>
<tbody>`)
<tbody>`, titlePat.ReplaceAllString(lines[0], ""))
// Print HTML docs/code segments.
for _, seg := range segments {