diff --git a/example/main.go b/example/main.go
index 8ff7955..7d2e54b 100644
--- a/example/main.go
+++ b/example/main.go
@@ -16,6 +16,7 @@
package main
import (
+ "bytes"
"flag"
"fmt"
"io/ioutil"
@@ -46,7 +47,7 @@ func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage:\n"+
" %s [options] [inputfile [outputfile]]\n\n"+
- "Options:\n", os.Args[0])
+ "Options:\n",os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
@@ -135,6 +136,19 @@ func main() {
}
if page {
+ // if it starts with an
, make that the title
+ title := ""
+ if bytes.HasPrefix(output, []byte("")) {
+ end := 0
+ // we know the buffer ends with a newline, so no need to check bounds
+ for output[end] != '\n' {
+ end++
+ }
+ if bytes.HasSuffix(output[:end], []byte("
")) {
+ title = string(output[len("") : end-len("
")])
+ }
+ }
+
ending := ""
if xhtml {
fmt.Fprint(out, "")
}
fmt.Fprintln(out, "")
- fmt.Fprintln(out, " ")
+ fmt.Fprintf(out, " %s\n", title)
fmt.Fprintf(out, " \n", ending)
fmt.Fprintf(out, " \n", ending)
if css != "" {