mirror of
https://github.com/asciimoo/wuzz
synced 2024-11-18 15:25:30 +00:00
30 lines
504 B
Go
30 lines
504 B
Go
package formatter
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
|
|
"github.com/x86kernel/htmlcolor"
|
|
)
|
|
|
|
type htmlFormatter struct {
|
|
textFormatter
|
|
}
|
|
|
|
func (f *htmlFormatter) Format(writer io.Writer, data []byte) error {
|
|
htmlFormatter := htmlcolor.NewFormatter()
|
|
buf := bytes.NewBuffer(make([]byte, 0, len(data)))
|
|
err := htmlFormatter.Format(buf, data)
|
|
|
|
if err == io.EOF {
|
|
writer.Write(buf.Bytes())
|
|
return nil
|
|
}
|
|
|
|
return errors.New("html formatter error")
|
|
}
|
|
|
|
func (f *htmlFormatter) Title() string {
|
|
return "[html]"
|
|
}
|