From c74f18acc27f9d27553f0f9b6d7bb8aa6010bbee Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 3 Jul 2026 13:24:18 +0200 Subject: [PATCH] handle text/makrdown as plain text --- src/browser/Frame.zig | 2 +- src/browser/Mime.zig | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig index 6bbdb152d..eb0e3b8e9 100644 --- a/src/browser/Frame.zig +++ b/src/browser/Frame.zig @@ -1398,7 +1398,7 @@ fn frameDataCallback(response: HttpClient.Response, data: []const u8) !void { .arena = try self.getArena(.large, "Frame.navigate"), } }; }, - .application_json, .text_javascript, .text_css, .text_plain => { + .application_json, .text_javascript, .text_css, .text_plain, .text_markdown => { var arr: std.ArrayList(u8) = .empty; try arr.appendSlice(self.arena, "
");
                 self._parse_state = .{ .text = arr };
diff --git a/src/browser/Mime.zig b/src/browser/Mime.zig
index 16a644fa4..402056079 100644
--- a/src/browser/Mime.zig
+++ b/src/browser/Mime.zig
@@ -40,6 +40,7 @@ pub const ContentTypeEnum = enum {
     text_javascript,
     text_plain,
     text_css,
+    text_markdown,
     image_jpeg,
     image_gif,
     image_png,
@@ -55,6 +56,7 @@ pub const ContentType = union(ContentTypeEnum) {
     text_javascript: void,
     text_plain: void,
     text_css: void,
+    text_markdown: void,
     image_jpeg: void,
     image_gif: void,
     image_png: void,
@@ -72,6 +74,7 @@ pub fn contentTypeString(mime: *const Mime) []const u8 {
         .text_html => "text/html",
         .text_javascript => "application/javascript",
         .text_plain => "text/plain",
+        .text_markdown => "text/markdown",
         .text_css => "text/css",
         .image_jpeg => "image/jpeg",
         .image_png => "image/png",
@@ -342,7 +345,7 @@ pub fn isHTML(self: *const Mime) bool {
 
 pub fn isText(mime: *const Mime) bool {
     return switch (mime.content_type) {
-        .text_xml, .text_html, .text_javascript, .text_plain, .text_css => true,
+        .text_xml, .text_html, .text_javascript, .text_plain, .text_css, .text_markdown => true,
         .application_json => true,
         else => false,
     };
@@ -359,6 +362,7 @@ fn parseContentType(value: []const u8) !struct { ContentType, usize } {
         @"text/html",
         @"text/css",
         @"text/plain",
+        @"text/markdown",
 
         @"text/javascript",
         @"application/javascript",
@@ -377,6 +381,7 @@ fn parseContentType(value: []const u8) !struct { ContentType, usize } {
             .@"text/javascript", .@"application/javascript", .@"application/x-javascript" => .{ .text_javascript = {} },
             .@"text/plain" => .{ .text_plain = {} },
             .@"text/css" => .{ .text_css = {} },
+            .@"text/markdown" => .{ .text_markdown = {} },
             .@"image/jpeg" => .{ .image_jpeg = {} },
             .@"image/png" => .{ .image_png = {} },
             .@"image/gif" => .{ .image_gif = {} },
@@ -790,6 +795,7 @@ test "Mime: parse common" {
 
     try expect(.{ .content_type = .{ .application_json = {} } }, "application/json");
     try expect(.{ .content_type = .{ .text_css = {} } }, "text/css");
+    try expect(.{ .content_type = .{ .text_markdown = {} } }, "text/markdown");
 
     try expect(.{ .content_type = .{ .image_jpeg = {} } }, "image/jpeg");
     try expect(.{ .content_type = .{ .image_png = {} } }, "image/png");