Skip to content

Commit e593896

Browse files
committed
CHORE: unfinished attempt to get more details in html errors
1 parent 19b2225 commit e593896

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/command/html.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,32 @@ func htmlCheck(f *shared.FileContext) {
5555
func validateHTML(r *bytes.Reader) error {
5656
d := xml.NewDecoder(r)
5757

58+
path := []string{}
59+
5860
//LATER: alternate parser [tdewolff/parse](https://github.com/tdewolff/parse)
5961

6062
// Configure the decoder for HTML; leave off strict and autoclose for XHTML
6163
d.Strict = false
6264
d.AutoClose = xml.HTMLAutoClose
6365
d.Entity = xml.HTMLEntity
6466
for {
65-
_, err := d.Token()
67+
theToken, err := d.Token()
6668
if err != nil {
6769
if err == io.EOF {
6870
return nil
6971
}
72+
//fmt.Printf("err %T path=%v\n", err, path)
7073
return err
7174
}
75+
switch typedToken := theToken.(type) {
76+
case xml.StartElement:
77+
path = append(path, typedToken.Name.Local)
78+
case xml.EndElement:
79+
path = path[:len(path)-1]
80+
default:
81+
// ignore
82+
}
83+
7284
}
7385
}
7486

0 commit comments

Comments
 (0)