%s
\n", esc(r.Note)) } var facts []string if l, ok := kindLabel[r.Kind]; ok { facts = append(facts, l) } if r.Maturity != "" { facts = append(facts, "maturity: "+r.Maturity) } facts = append(facts, fmt.Sprintf("+%d / −%d words", r.Stats.WordsAdded, r.Stats.WordsRemoved)) fmt.Fprintf(&b, "%s
\n", esc(strings.Join(facts, " · "))) for _, m := range r.MetaChanges { if m.Key == "maturity" { continue // already in the summary line } fmt.Fprintf(&b, "%s: %s %s
…
\n") } fmt.Fprintf(&b, "Read version %d · Current page · History
\n", esc(r.VersionURL), r.Number, esc(r.Page.URL), esc(r.HistoryURL)) return b.String() } func opHTML(op diff.Op) string { wrap := func(inner string) string { switch op.Kind { case doc.KindCode, doc.KindTable: return "" + inner + "\n" case doc.KindHeading: return "
" + inner + "\n" case doc.KindListItem: return "
" + inner + "
\n" } switch op.Op { case diff.OpGap: if op.Removed { return fmt.Sprintf("[%d more removed]
[%d unchanged]
\n", op.Count) case diff.OpEq: return wrap(esc(op.Text)) case diff.OpInsert: return wrap("" + esc(op.Text) + "") case diff.OpDelete: return wrap("[moved]
\n" + wrap(esc(op.Text)) case diff.OpModify: if op.Replaced { // Rewritten block: old and new side by side would run together. var out strings.Builder for _, s := range op.Segments { tag := "ins" if s.T == diff.SegDel { tag = "del" } out.WriteString(wrap("<" + tag + ">" + esc(s.S) + "" + tag + ">")) } return out.String() } var in strings.Builder for i, s := range op.Segments { switch s.T { case diff.SegDel: in.WriteString("