Commit 12f8660d authored by Robert Griesemer's avatar Robert Griesemer

use default styler when there is no other given

(No visual change yet since the comments for
exported code snippets - as shown on the pkg
page - are not yet formatted using the standard
comment intersperse mechanism in the printer.
This is a TODO in the printer.)

R=rsc
http://go/go-review/1016031
parent 929e27e3
...@@ -300,6 +300,10 @@ type Styler struct { ...@@ -300,6 +300,10 @@ type Styler struct {
} }
// Use the defaultStyler when there is no specific styler.
var defaultStyler Styler
func (s *Styler) LineTag(line int) (text []byte, tag printer.HtmlTag) { func (s *Styler) LineTag(line int) (text []byte, tag printer.HtmlTag) {
tag = printer.HtmlTag{fmt.Sprintf(`<a id="L%d">`, line), "</a>"}; tag = printer.HtmlTag{fmt.Sprintf(`<a id="L%d">`, line), "</a>"};
return; return;
...@@ -367,9 +371,9 @@ func writeAny(w io.Writer, x interface{}, html bool) { ...@@ -367,9 +371,9 @@ func writeAny(w io.Writer, x interface{}, html bool) {
case string: case string:
writeText(w, strings.Bytes(v), html); writeText(w, strings.Bytes(v), html);
case ast.Decl: case ast.Decl:
writeNode(w, v, html, nil); writeNode(w, v, html, &defaultStyler);
case ast.Expr: case ast.Expr:
writeNode(w, v, html, nil); writeNode(w, v, html, &defaultStyler);
default: default:
if html { if html {
var buf bytes.Buffer; var buf bytes.Buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment