File: html.go

package info (click to toggle)
wuzz 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 372 kB
  • sloc: makefile: 6
file content (30 lines) | stat: -rw-r--r-- 514 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package formatter

import (
	"bytes"
	"errors"
	"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]"
}