Skip to content

Commit

Permalink
flatten results
Browse files Browse the repository at this point in the history
  • Loading branch information
bjesus committed Sep 12, 2024
1 parent ac6642f commit 30fddcc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/pipet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func runPipet(c *cli.Context, specFile string) error {
}

log.Println("Generating output")

if jsonOutput {
newValue = outputs.OutputJSON(pipet)
} else if templateFile != "" {
Expand Down
10 changes: 8 additions & 2 deletions parsers/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/PuerkitoBio/goquery"
)

func ParseHTMLQueries(htmlData []byte, queries []string, nextPage string) (interface{}, string, error) {
func ParseHTMLQueries(htmlData []byte, queries []string, nextPage string) ([]interface{}, string, error) {

result := []interface{}{}

Expand Down Expand Up @@ -43,7 +43,13 @@ func ParseHTMLQueries(htmlData []byte, queries []string, nextPage string) (inter
html = "<table>" + html + "</table>"
}
value2, _, _ := ParseHTMLQueries([]byte(html), lines, "")
subresult = append(subresult, value2)

if len(value2) == 1 {
subresult = append(subresult, value2[0])
} else {
subresult = append(subresult, value2)
}

})

result = append(result, subresult)
Expand Down

0 comments on commit 30fddcc

Please sign in to comment.