accept path-only diagram entries

This commit is contained in:
2026-10-23 16:38:24 +02:00
committed by owenrees
parent 548f98f303
commit 9cd7878ad8
5 changed files with 147 additions and 7 deletions
+4 -2
View File
@@ -10,10 +10,12 @@ let parse_diagrams_json diagrams_json_str =
let diagrams_list = to_list json in
List.fold_left
(fun acc item ->
let ply = item |> member "ply" |> to_int in
let fen = item |> member "fen" |> to_string in
let acc =
{ acc with Ast.by_ply = MoveMap.add ply fen acc.Ast.by_ply }
match item |> member "ply" with
| `Int ply ->
{ acc with Ast.by_ply = MoveMap.add ply fen acc.Ast.by_ply }
| _ -> acc
in
match item |> member "path" with
| `List path_items ->
+4 -2
View File
@@ -25,8 +25,10 @@ val parse_diagrams_json : string -> diagram_data
(** [parse_diagrams_json json] parses diagram selections from a JSON string.
The input is expected to be a JSON array of objects. Each object contains
a [fen] string and may contain a [ply] number and a [path] array of SAN
moves. Malformed JSON yields {!empty_diagrams} rather than raising. *)
a [fen] string and either a legacy [ply] number, a [path] array of SAN
moves, or both. A matching [path] takes precedence; [ply] is the fallback
for mainline positions. Malformed JSON yields {!empty_diagrams} rather than
raising. *)
val to_tex : ?diagram_data:diagram_data -> ?clock:bool -> string -> string
(** [to_tex pgn] converts the PGN game in [pgn] to a LaTeX fragment.