My aggregated monorepo of OCaml code, automaintained

Squashed 'ocaml-frontmatter/' changes from cd286545..5d9d79a4

5d9d79a4 Fix JSON feed differences: slugs, PDFs, DOI cache

git-subtree-dir: ocaml-frontmatter
git-subtree-split: 5d9d79a47a9a2916f6269832d89c0c763c5bec7f

+12 -2
+12 -2
lib/frontmatter.ml
··· 36 36 with _ -> None 37 37 else None 38 38 39 + (** Normalize a slug to match Jekyll's slug_of_string behavior: 40 + map all non-alphanumeric characters to hyphens and lowercase. *) 41 + let normalize_slug s = 42 + let mapped = String.map (fun c -> 43 + match c with 44 + | 'a'..'z' | 'A'..'Z' | '0'..'9' -> c 45 + | _ -> '-' 46 + ) s in 47 + String.lowercase_ascii mapped 48 + 39 49 let slug_of_fname fname = 40 50 let basename = Filename.basename fname in 41 51 let no_ext = Filename.chop_extension basename in 42 52 match parse_date_prefix no_ext with 43 - | Some (date, slug) -> Ok (slug, Some date) 44 - | None -> Ok (no_ext, None) 53 + | Some (date, slug) -> Ok (normalize_slug slug, Some date) 54 + | None -> Ok (normalize_slug no_ext, None) 45 55 46 56 (** Parse frontmatter using yamlrw's streaming parser. 47 57 Uses multi-document support to find the document boundary,