this repo has no description

Deduplicate extension resources in HTML output

When a page uses the same extension multiple times (e.g., multiple
mermaid diagrams), the extension's resources (JS/CSS) were being
included once per use. This caused duplicate script and stylesheet
tags in the HTML output.

Add a deduplicate_resources helper that removes duplicates while
preserving order (keeping first occurrence) before rendering
resources to HTML.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+11
+11
src/html/html_page.ml
··· 183 183 (Html.txt ""); 184 184 ] 185 185 in 186 + (* Deduplicate resources while preserving order (keep first occurrence) *) 187 + let deduplicate_resources resources = 188 + let rec aux seen acc = function 189 + | [] -> List.rev acc 190 + | r :: rest -> 191 + if List.mem r seen then aux seen acc rest 192 + else aux (r :: seen) (r :: acc) rest 193 + in 194 + aux [] [] resources 195 + in 186 196 (* Convert extension resources to HTML elements *) 187 197 let extension_resources = 188 198 let open Odoc_extension_registry in ··· 190 200 String.is_prefix ~affix:"http://" url || 191 201 String.is_prefix ~affix:"https://" url 192 202 in 203 + let resources = deduplicate_resources resources in 193 204 List.concat_map 194 205 (function 195 206 | Js_url url ->