From a08fc6ddfed854f0ec7b758414351ce325eccb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Thu, 4 Jun 2026 20:29:36 +0200 Subject: [PATCH] fix: strip leading UTF-8 BOM from aggregated GitHub content The GitHub API returns file bytes verbatim, so a UTF-8 BOM in a source file (e.g. an extension's Docs/pages/00-index.md) survived decoding and landed at the start of the rendered page. A leading BOM before the first markdown heading stops Docusaurus from parsing it (the heading renders as a literal paragraph) and also breaks StripReadmeFront's H1 detection, since char.IsWhiteSpace(U+FEFF) is false. Drop it once at the single Base64Decode chokepoint so every aggregated file and README is BOM-free. --- Pipeline/Build.Pages.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Pipeline/Build.Pages.cs b/Pipeline/Build.Pages.cs index 7bee7852..9bac8c0a 100644 --- a/Pipeline/Build.Pages.cs +++ b/Pipeline/Build.Pages.cs @@ -339,6 +339,11 @@ static string EnsureSidebarPosition(string content, int position) static string Base64Decode(string base64EncodedData) { byte[] base64EncodedBytes = Convert.FromBase64String(base64EncodedData); - return Encoding.UTF8.GetString(base64EncodedBytes); + // The GitHub API returns file bytes verbatim, so a UTF-8 BOM survives into the + // decoded string. A leading BOM (U+FEFF) before the first markdown heading stops + // Docusaurus from parsing it (the heading renders as a literal paragraph) and also + // breaks StripReadmeFront's H1 detection, since char.IsWhiteSpace('') is false + // and TrimStart() leaves it in place. Drop it once at the single decode chokepoint. + return Encoding.UTF8.GetString(base64EncodedBytes).TrimStart(''); } }