From d0a2f9b05a5df95f3d2800cb899c998d3c8d5fb6 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 8 Oct 2026 19:57:40 +0200 Subject: html-parser: fix custom element parsing --- src/z/html/parser.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/z/html') diff --git a/src/z/html/parser.zig b/src/z/html/parser.zig index ee926f1..c85cc16 100644 --- a/src/z/html/parser.zig +++ b/src/z/html/parser.zig @@ -5,7 +5,7 @@ const Attribute = mod.Attribute; const Tag = mod.Tag; const Fragment = mod.Fragment; -const alphanumeric: []const u8 = std.ascii.letters ++ .{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; +const tag_name: []const u8 = std.ascii.letters ++ .{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-' }; const void_elements: std.StaticStringMap(void) = .initComptime(.{ .{"area"}, .{"base"}, @@ -58,7 +58,7 @@ pub fn tag(buffer: []const u8) struct { Tag, []const u8 } { var buf: []const u8 = buffer[1..]; const name = name: { - const index = std.mem.findNone(u8, buf, alphanumeric) orelse @panic("uncosed tag"); + const index = std.mem.findNone(u8, buf, tag_name) orelse @panic("uncosed tag"); defer buf = buf[index..]; break :name buf[0..index]; }; @@ -137,7 +137,7 @@ pub fn attribute(buffer: []const u8) struct { Attribute, []const u8 } { buf = std.mem.trimStart(u8, buf, &std.ascii.whitespace); if (buf.len == 0 or buf[0] == '>') { - return .{ .name = name, .value = "" }; + return .{ .{ .name = name, .value = "" }, buf }; } if (buf[0] != '=') @panic("expected attr-eql"); -- cgit v1.2.3-70-g09d2