add title
This commit is contained in:
parent
f57c28f42c
commit
dbf69907cc
@ -3,7 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
||||||
<title>Page Title</title>
|
<title>golit</title>
|
||||||
<link rel=stylesheet href="book.css">
|
<link rel=stylesheet href="book.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -35,6 +35,11 @@ documentation form Go source files.</p>
|
|||||||
<tr><td class=docs><p>Recognize doc lines, extract their comment prefixes.</p>
|
<tr><td class=docs><p>Recognize doc lines, extract their comment prefixes.</p>
|
||||||
</td><td class=code><div class="highlight"><pre><span class="k">var</span> <span class="n">docsPat</span> <span class="p">=</span> <span class="n">regexp</span><span class="p">.</span><span class="n">MustCompile</span><span class="p">(</span><span class="s">"^\\s*\\/\\/\\s"</span><span class="p">)</span>
|
</td><td class=code><div class="highlight"><pre><span class="k">var</span> <span class="n">docsPat</span> <span class="p">=</span> <span class="n">regexp</span><span class="p">.</span><span class="n">MustCompile</span><span class="p">(</span><span class="s">"^\\s*\\/\\/\\s"</span><span class="p">)</span>
|
||||||
|
|
||||||
|
</pre></div>
|
||||||
|
</td></tr>
|
||||||
|
<tr><td class=docs><p>Recognize title prefixes, for titling web page.</p>
|
||||||
|
</td><td class=code><div class="highlight"><pre><span class="k">var</span> <span class="n">titlePat</span> <span class="p">=</span> <span class="n">regexp</span><span class="p">.</span><span class="n">MustCompile</span><span class="p">(</span><span class="s">"^\\/\\/\\s##\\s"</span><span class="p">)</span>
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class=docs><p>Abort on non-nil errors.</p>
|
<tr><td class=docs><p>Abort on non-nil errors.</p>
|
||||||
@ -148,12 +153,12 @@ Special case the header to go in its own segment.</p>
|
|||||||
</pre></div>
|
</pre></div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class=docs><p>Print HTML header.</p>
|
<tr><td class=docs><p>Print HTML header.</p>
|
||||||
</td><td class=code><div class="highlight"><pre> <span class="n">fmt</span><span class="p">.</span><span class="n">Print</span><span class="p">(</span><span class="s">`</span>
|
</td><td class=code><div class="highlight"><pre> <span class="n">fmt</span><span class="p">.</span><span class="n">Printf</span><span class="p">(</span><span class="s">`</span>
|
||||||
<span class="s"><!DOCTYPE html></span>
|
<span class="s"><!DOCTYPE html></span>
|
||||||
<span class="s"><html></span>
|
<span class="s"><html></span>
|
||||||
<span class="s"> <head></span>
|
<span class="s"> <head></span>
|
||||||
<span class="s"> <meta http-eqiv="content-type" content="text/html;charset=utf-8"></span>
|
<span class="s"> <meta http-eqiv="content-type" content="text/html;charset=utf-8"></span>
|
||||||
<span class="s"> <title>Page Title</title></span>
|
<span class="s"> <title>%s</title></span>
|
||||||
<span class="s"> <link rel=stylesheet href="book.css"></span>
|
<span class="s"> <link rel=stylesheet href="book.css"></span>
|
||||||
<span class="s"> </head></span>
|
<span class="s"> </head></span>
|
||||||
<span class="s"> <body></span>
|
<span class="s"> <body></span>
|
||||||
@ -163,7 +168,7 @@ Special case the header to go in its own segment.</p>
|
|||||||
<span class="s"> <thead></span>
|
<span class="s"> <thead></span>
|
||||||
<span class="s"> <tr><td class=docs></td><td class=code></td></tr></span>
|
<span class="s"> <tr><td class=docs></td><td class=code></td></tr></span>
|
||||||
<span class="s"> </thead></span>
|
<span class="s"> </thead></span>
|
||||||
<span class="s"> <tbody>`</span><span class="p">)</span>
|
<span class="s"> <tbody>`</span><span class="p">,</span> <span class="n">titlePat</span><span class="p">.</span><span class="n">ReplaceAllString</span><span class="p">(</span><span class="n">lines</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s">""</span><span class="p">))</span>
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
@ -17,6 +17,9 @@ import (
|
|||||||
// Recognize doc lines, extract their comment prefixes.
|
// Recognize doc lines, extract their comment prefixes.
|
||||||
var docsPat = regexp.MustCompile("^\\s*\\/\\/\\s")
|
var docsPat = regexp.MustCompile("^\\s*\\/\\/\\s")
|
||||||
|
|
||||||
|
// Recognize title prefixes, for titling web page.
|
||||||
|
var titlePat = regexp.MustCompile("^\\/\\/\\s##\\s")
|
||||||
|
|
||||||
// Abort on non-nil errors.
|
// Abort on non-nil errors.
|
||||||
func check(err error) {
|
func check(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -108,12 +111,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print HTML header.
|
// Print HTML header.
|
||||||
fmt.Print(`
|
fmt.Printf(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
||||||
<title>Page Title</title>
|
<title>%s</title>
|
||||||
<link rel=stylesheet href="book.css">
|
<link rel=stylesheet href="book.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -123,7 +126,7 @@ func main() {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr><td class=docs></td><td class=code></td></tr>
|
<tr><td class=docs></td><td class=code></td></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>`)
|
<tbody>`, titlePat.ReplaceAllString(lines[0], ""))
|
||||||
|
|
||||||
// Print HTML docs/code segments.
|
// Print HTML docs/code segments.
|
||||||
for _, seg := range segments {
|
for _, seg := range segments {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user