Merge pull request #6113 from StudebakerGuy/xmlcomment

core:encoding/xml comments not handled correctly before first element and include --
This commit is contained in:
Jeroen van Rijn
2026-01-22 11:57:31 +01:00
committed by GitHub
3 changed files with 6 additions and 6 deletions

View File

@@ -264,7 +264,7 @@ scan_comment :: proc(t: ^Tokenizer) -> (comment: string, err: Error) {
expect(t, .Dash)
expect(t, .Gt)
return string(t.src[offset : t.offset - 1]), .None
return string(t.src[offset : t.offset - 3]), .None
}
// Skip CDATA

View File

@@ -294,7 +294,7 @@ parse_bytes :: proc(data: []u8, options := DEFAULT_OPTIONS, path := "", error_ha
comment := scan_comment(t) or_return
if .Intern_Comments in opts.flags {
if len(doc.elements) == 0 {
if doc.element_count == 0 {
append(&doc.comments, comment)
} else {
el := new_element(doc)

View File

@@ -114,7 +114,7 @@ xml_test_entities :: proc(t: ^testing.T) {
},
expected_doctype = "html",
},
crc32 = 0x48f41216,
crc32 = 0x98791215,
})
}
@@ -128,7 +128,7 @@ xml_test_entities_unbox :: proc(t: ^testing.T) {
},
expected_doctype = "html",
},
crc32 = 0xd0567818,
crc32 = 0x5fd5ab4e,
})
}
@@ -142,7 +142,7 @@ xml_test_entities_unbox_decode :: proc(t: ^testing.T) {
},
expected_doctype = "html",
},
crc32 = 0x6e45a697,
crc32 = 0xda1ac384,
})
}
@@ -298,4 +298,4 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
print(strings.to_writer(&buf), doc)
return strings.clone(strings.to_string(buf))
}
}