mirror of
https://github.com/TheRealOwenRees/pgn_to_tex.git
synced 2026-11-18 04:42:07 +00:00
accept path-only diagram entries
This commit is contained in:
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user