Feature/variations (#5)

* support diagrams in variations.

* Diagram data now carries an optional `path` (the SAN move sequence from the root) alongside the legacy `ply`; diagrams whose `path` resolves inside a variation are rendered inline within the variation. `parse_diagrams_json` returns a `diagram_data` record with `by_ply` and `by_path` maps.

* make variation boards slightly smaller than the mainline boards

* update changelog v0.0.2
This commit is contained in:
2026-10-18 20:06:43 +02:00
committed by GitHub
parent 5831ddfb5e
commit fe9eb8ba45
12 changed files with 207 additions and 79 deletions
+2 -17
View File
@@ -2,21 +2,6 @@ open Js_of_ocaml
open Pgn_logic
open Ast
let parse_diagram_json json_str =
let json = Yojson.Basic.from_string json_str in
let json_list = Yojson.Basic.Util.to_list json in
List.fold_left
(fun acc item ->
let move_int =
item |> Yojson.Basic.Util.member "ply" |> Yojson.Basic.Util.to_int
in
let fen_str =
item |> Yojson.Basic.Util.member "fen" |> Yojson.Basic.Util.to_string
in
Pgn2tex.MoveMap.add move_int fen_str acc)
Pgn2tex.MoveMap.empty json_list
let convert_js pgn_js diagram_json_js display_clock =
let pgn = Js.to_string pgn_js in
@@ -24,8 +9,8 @@ let convert_js pgn_js diagram_json_js display_clock =
let json_str = Js.to_string diagram_json_js in
let diagram_data =
if json_str = "" || json_str = "{}" then Pgn2tex.MoveMap.empty
else parse_diagram_json json_str
if json_str = "" || json_str = "{}" then Ast.empty_diagrams
else Pgn2tex.parse_diagrams_json json_str
in
let result = Pgn2tex.to_tex pgn ~diagram_data ~clock:display_clock in