mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-03-04 14:56:35 +00:00
Initial commit
This commit is contained in:
35
internal/html.go
Normal file
35
internal/html.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// HTMLWriter writes HTML output with optional header/footer.
|
||||
type HTMLWriter struct {
|
||||
Header string
|
||||
Footer string
|
||||
}
|
||||
|
||||
func (w *HTMLWriter) Write(output string, path string) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = f.Close() // Ignore close error in defer
|
||||
}()
|
||||
if w.Header != "" {
|
||||
if _, err := f.WriteString(w.Header); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := f.WriteString(output); err != nil {
|
||||
return err
|
||||
}
|
||||
if w.Footer != "" {
|
||||
if _, err := f.WriteString(w.Footer); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user