1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:20:12 -07:00
go/usr/gri/pretty/htmlwriter.go
Robert Griesemer 77aaf4f3a2 - adjusted const decl grammar to reflect spec changes
- first cut at html writer (will do html escaping, html tag production)
- first cut at generating basic html output via pretty
- some cleanups

R=r
OCL=20550
CL=20550
2008-12-04 18:18:41 -08:00

44 lines
901 B
Go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package htmlwriter
import (
"os";
"io";
"array";
"utf8";
)
// Writer is a filter implementing the io.Write interface.
// It provides facilities to generate HTML tags and does
// proper HTML-escaping for text written through it.
export type Writer struct {
// TODO should not export any of the fields
writer io.Write;
}
func (b *Writer) Init(writer io.Write) *Writer {
b.writer = writer;
return b;
}
/* export */ func (b *Writer) Flush() *os.Error {
return nil;
}
/* export */ func (b *Writer) Write(buf *[]byte) (written int, err *os.Error) {
written, err = b.writer.Write(buf); // BUG 6g - should just have return
return written, err;
}
export func New(writer io.Write) *Writer {
return new(Writer).Init(writer);
}