2024-10-11 15:25:41 +00:00
|
|
|
// Forked from https://github.com/PiotrKowalski/html-to-gomponents
|
|
|
|
|
|
2024-10-11 16:19:32 +00:00
|
|
|
package htmltogo
|
2024-10-11 15:25:41 +00:00
|
|
|
|
|
|
|
|
import (
|
2024-10-11 15:28:34 +00:00
|
|
|
serviceformatter "github.com/maddalax/htmgo/tools/html-to-htmgo/internal/adapters/services/formatter"
|
|
|
|
|
serviceparser "github.com/maddalax/htmgo/tools/html-to-htmgo/internal/adapters/services/parser"
|
2024-10-11 15:25:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Parse(input []byte) []byte {
|
|
|
|
|
parser := serviceparser.New()
|
|
|
|
|
formatter := serviceformatter.New()
|
|
|
|
|
parsed, err := parser.FromBytes(
|
|
|
|
|
input,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-25 15:33:48 +00:00
|
|
|
return []byte(Indent(formatter.Format(parsed)))
|
2024-10-11 15:25:41 +00:00
|
|
|
}
|