return lines
}
+func lineURLize(urlPrefix, line string) string {
+ cols := strings.Split(html.EscapeString(line), " ")
+ for i, col := range cols {
+ if u := urlParse(col); u != nil {
+ cols[i] = makeA(col, col)
+ continue
+ }
+ cols[i] = sha1DigestRe.ReplaceAllString(col, makeA(
+ urlPrefix+"/$1", "$1",
+ ))
+ }
+ return strings.Join(cols, " ")
+}
+
func getNote(tree *object.Tree, what plumbing.Hash) []byte {
if tree == nil {
return nil
when, commit.Hash.String(), title,
)))
for _, line := range lines[2:] {
- line = html.EscapeString(line)
- cols := strings.Split(line, " ")
- for i, col := range cols {
- if u := urlParse(col); u != nil {
- cols[i] = makeA(col, col)
- continue
- }
- cols[i] = sha1DigestRe.ReplaceAllString(col, makeA(
- cfg.URLPrefix+"/$1", "$1",
- ))
- }
- line = strings.Join(cols, " ")
- out.Write([]byte(line + "\n"))
+ out.Write([]byte(lineURLize(cfg.URLPrefix, line) + "\n"))
}
out.Write([]byte("</pre>\n<hr/>\n"))
if len(notesRaw) > 0 {
for i, comment := range parseComments(commentsRaw) {
out.Write([]byte(fmt.Sprintf(
"<dt><a name=\"comment%d\"><a href=\"#comment%d\">comment %d</a>:"+
- "</dt>\n<dd><pre>\n%s\n</pre></dd>\n",
- i, i, i, html.EscapeString(comment),
+ "</dt>\n<dd><pre>\n",
+ i, i, i,
)))
+ lines = strings.Split(comment, "\n")
+ for _, line := range lines[:3] {
+ out.Write([]byte(line + "\n"))
+ }
+ for _, line := range lines[3:] {
+ out.Write([]byte(lineURLize(cfg.URLPrefix, line) + "\n"))
+ }
+ out.Write([]byte("</pre></dd>\n"))
}
out.Write([]byte("</dl>\n"))
} else {