mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-12 21:59:29 +01:00
Construct screen
This commit is contained in:
parent
0911ba8646
commit
912fe49ab3
1 changed files with 5 additions and 2 deletions
|
@ -58,13 +58,16 @@ func (Renderer) CanRender(filename string, input io.Reader) bool {
|
||||||
|
|
||||||
// Render renders terminal colors to HTML with all specific handling stuff.
|
// Render renders terminal colors to HTML with all specific handling stuff.
|
||||||
func (Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error {
|
func (Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error {
|
||||||
screen := &trend.Screen{}
|
screen, err := trend.NewScreen()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if _, err := io.Copy(screen, input); err != nil {
|
if _, err := io.Copy(screen, input); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
buf := screen.AsHTML()
|
buf := screen.AsHTML()
|
||||||
buf = strings.ReplaceAll(buf, "\n", `<br>`)
|
buf = strings.ReplaceAll(buf, "\n", `<br>`)
|
||||||
_, err := output.Write([]byte(buf))
|
_, err = output.Write([]byte(buf))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue