* update documentation link

* remove superfluous tests

* add game example with subtitle custom header

* remove commented out code

* fix subtitle by making it a new line of smaller text within the title

* update changelog with v0.0.1
This commit is contained in:
2026-06-29 21:18:10 +02:00
committed by GitHub
parent b4816553c7
commit a58a6504b4
6 changed files with 14 additions and 63 deletions
+5
View File
@@ -1,3 +1,8 @@
## v0.0.1
- fix bug whereby a `subtitle` custom PGN header was rendering on a separate page. It now appears under the title
- remove old tests and commented out code
## v0.0.1-rc.2 ## v0.0.1-rc.2
- add correct versioning metadata - add correct versioning metadata
+1 -1
View File
@@ -34,7 +34,7 @@ let build_title_string event title subtitle =
match (event, title, subtitle) with match (event, title, subtitle) with
| event, "", "" -> "\\title{" ^ escape_tex event ^ "}" | event, "", "" -> "\\title{" ^ escape_tex event ^ "}"
| _event, title, subtitle -> | _event, title, subtitle ->
"\\title{" ^ title ^ "}\\\\[2ex]\\large{" ^ subtitle ^ "}" "\\title{" ^ title ^ "\\\\[2ex]\\large{" ^ subtitle ^ "}}"
(* Date and Site string builder *) (* Date and Site string builder *)
let build_date_site_string date site = let build_date_site_string date site =
-12
View File
@@ -28,15 +28,3 @@ let parse_pgn s =
in in
try MenhirLib.Convert.Simplified.traditional2revised Parser.main provider try MenhirLib.Convert.Simplified.traditional2revised Parser.main provider
with _ -> failwith "Parse error" with _ -> failwith "Parse error"
(* let parse_diagram_json json_str =
let json = Yojson.Basic.from_string json_str in
let json_assoc = Yojson.Basic.Util.to_assoc json in
List.fold_left
(fun acc (key_str, json_value) ->
let value_string = Yojson.Basic.Util.to_string json_value in
match int_of_string_opt key_str with
| Some k -> Pgn2tex.MoveMap.add k value_string acc
| None -> acc)
Pgn2tex.MoveMap.empty json_assoc *)
+7
View File
@@ -0,0 +1,7 @@
[Result "*"]
[Title "Some Title"]
[Subtitle "Some Subtitle"]
[Date "2025.12.23"]
[Author "Some Author"]
1. d4 d5 2. c4 dxc4 3. e4 Nf6 4. e5 Nd5 5. Bxc4 Nb6 6. Bb3 e6 (6... Nc6) 7. Nf3 c5 8. Be3 N8d7 9. O-O c4 10. Bc2 Nd5 11. Nc3 N7b6 12. Be4 Bb4 13. Bxd5 Nxd5? (13... Bxc3) 14. Nxd5 exd5 15. Qa4+ Bd7 16. Qxb4 Qb6 17. Qxb6 axb6 18. Rfc1 O-O 19. Nd2 Bf5 20. b3 b5 21. a4 cxb3 22. Nxb3 bxa4 23. Nc5 b5 24. Bd2 Rfe8 25. Bb4 Rac8 26. Nb7 Rxc1+ 27. Rxc1 Rc8 28. Rxc8+ Bxc8 29. Nd6 Bd7 30. f4 g6 31. Kf2 Kg7 32. h3 *
+1 -1
View File
@@ -111,7 +111,7 @@ let test_title =
ae "\\title{some event}" ae "\\title{some event}"
(Latex_helpers.build_title_string "some event" "" "") ); (Latex_helpers.build_title_string "some event" "" "") );
( "Title and subtitle" >:: fun _ -> ( "Title and subtitle" >:: fun _ ->
ae "\\title{Some title}\\\\[2ex]\\large{Some subtitle}" ae "\\title{Some title\\\\[2ex]\\large{Some subtitle}}"
(Latex_helpers.build_title_string "irrelevant" "Some title" (Latex_helpers.build_title_string "irrelevant" "Some title"
"Some subtitle") ); "Some subtitle") );
] ]
-49
View File
@@ -83,61 +83,12 @@ let test_pgn_with_clock_to_tex _ctxt =
ae expected actual; ae expected actual;
close_in ic close_in ic
let test_pgn_with_unsupported_text _ctxt =
let filename = "pgn_examples/4.pgn" in
let ic = In_channel.open_text filename in
let input_string = In_channel.input_all ic in
let actual = Pgn2tex.to_tex input_string ~diagram_data ~clock:true in
let expected =
{|\title{Casual Rapid game}
\author{montillo2015 (1919) vs. reassessyourchess (1869)}
\date{2023.12.03, https://lichess.org/9Z0taHcG}\maketitle
\newchessgame
\textbf{1.} \textbf{d4} \textbf{1...} \textbf{Nf6} \textbf{2.} \textbf{Nf3} \textbf{2...} \textbf{d5} \textbf{3.} \textbf{e3}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:00\par \textbf{3...} \textbf{e6}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:01\par \newline D05 Queen's Pawn Game: Colle System\par \textbf{4.} \textbf{a3} \textbf{4...} \textbf{c5} \textbf{5.} \textbf{c4} \textbf{5...} \textbf{Nc6}\par\nobreak 0:10:02\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:02\par \textbf{6.} \textbf{dxc5} \textbf{6...} \textbf{Bxc5} \textbf{7.} \textbf{b4} \textbf{7...} \textbf{Be7} \textbf{8.} \textbf{Bb2}\par\nobreak 0:10:00\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:03\par \textbf{8...} \textbf{dxc4} \textbf{9.} \textbf{Qxd8+} \textbf{9...} \textbf{Nxd8} \textbf{10.} \textbf{Bxc4} \textbf{10...} \textbf{O-O} \textbf{11.} \textbf{O-O} \textbf{11...} \textbf{a6} \textbf{12.} \textbf{Nc3} \textbf{12...} \textbf{b5} \textbf{13.} \textbf{Be2} \textbf{13...} \textbf{Bb7} \textbf{14.} \textbf{Nd4} \textbf{14...} \textbf{Ne4} \textbf{15.} \textbf{Nxe4} \textbf{15...} \textbf{Bxe4} \textbf{16.} \textbf{Bf3} \textbf{16...} \textbf{Bxf3} \textbf{17.} \textbf{Nxf3} \textbf{17...} \textbf{Nc6} \textbf{18.} \textbf{Rac1} \textbf{18...} \textbf{Rac8} \textbf{19.} \textbf{Rfd1} \textbf{19...} \textbf{Rfd8} \textbf{20.} \textbf{Rxd8+} \textbf{20...} \textbf{Rxd8} \textbf{21.} \textbf{g3} \textbf{21...} \textbf{Nb8} \textbf{22.} \textbf{Rc7} \textbf{22...} \textbf{Bd6} \textbf{23.} \textbf{Rc2} \textbf{23...} \textbf{f6} \textbf{24.} \textbf{Kg2} \textbf{24...} \textbf{e5} \textbf{25.} \textbf{h4} \textbf{25...} \textbf{e4} \textbf{26.} \textbf{Nd4} \textbf{26...} \textbf{Kf7} \textbf{27.} \textbf{Nf5} \textbf{27...} \textbf{Nd7} \textbf{28.} \textbf{Nxd6+} \newline Black resigns.\par \textbf{1-0}|}
in
ae expected actual;
close_in ic
let test_pgn_with_custom_headers _ctxt =
let filename = "pgn_examples/7.pgn" in
let ic = In_channel.open_text filename in
let input_string = In_channel.input_all ic in
let actual = Pgn2tex.to_tex input_string ~diagram_data ~clock:false in
let expected =
{|\title{Casual Rapid game}
\author{montillo2015 (1919) vs. reassessyourchess (1869)}
\date{2023.12.03, https://lichess.org/9Z0taHcG}\maketitle
\newchessgame
\textbf{1.} \textbf{d4} \textbf{1...} \textbf{Nf6} \textbf{2.} \textbf{Nf3} \textbf{2...} \textbf{d5} \textbf{3.} \textbf{e3}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:00\par \textbf{3...} \textbf{e6}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:01\par \newline D05 Queen's Pawn Game: Colle System\par \textbf{4.} \textbf{a3} \textbf{4...} \textbf{c5} \textbf{5.} \textbf{c4} \textbf{5...} \textbf{Nc6}\par\nobreak 0:10:02\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:02\par \textbf{6.} \textbf{dxc5} \textbf{6...} \textbf{Bxc5} \textbf{7.} \textbf{b4} \textbf{7...} \textbf{Be7} \textbf{8.} \textbf{Bb2}\par\nobreak 0:10:00\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:03\par \textbf{8...} \textbf{dxc4} \textbf{9.} \textbf{Qxd8+} \textbf{9...} \textbf{Nxd8} \textbf{10.} \textbf{Bxc4} \textbf{10...} \textbf{O-O} \textbf{11.} \textbf{O-O} \textbf{11...} \textbf{a6} \textbf{12.} \textbf{Nc3} \textbf{12...} \textbf{b5} \textbf{13.} \textbf{Be2} \textbf{13...} \textbf{Bb7} \textbf{14.} \textbf{Nd4} \textbf{14...} \textbf{Ne4} \textbf{15.} \textbf{Nxe4} \textbf{15...} \textbf{Bxe4} \textbf{16.} \textbf{Bf3} \textbf{16...} \textbf{Bxf3} \textbf{17.} \textbf{Nxf3} \textbf{17...} \textbf{Nc6} \textbf{18.} \textbf{Rac1} \textbf{18...} \textbf{Rac8} \textbf{19.} \textbf{Rfd1} \textbf{19...} \textbf{Rfd8} \textbf{20.} \textbf{Rxd8+} \textbf{20...} \textbf{Rxd8} \textbf{21.} \textbf{g3} \textbf{21...} \textbf{Nb8} \textbf{22.} \textbf{Rc7} \textbf{22...} \textbf{Bd6} \textbf{23.} \textbf{Rc2} \textbf{23...} \textbf{f6} \textbf{24.} \textbf{Kg2} \textbf{24...} \textbf{e5} \textbf{25.} \textbf{h4} \textbf{25...} \textbf{e4} \textbf{26.} \textbf{Nd4} \textbf{26...} \textbf{Kf7} \textbf{27.} \textbf{Nf5} \textbf{27...} \textbf{Nd7} \textbf{28.} \textbf{Nxd6+} \newline Black resigns.\par \textbf{1-0}|}
in
ae expected actual;
close_in ic
let test_pgn_with_different_unsupported_text _ctxt =
let filename = "pgn_examples/10.pgn" in
let ic = In_channel.open_text filename in
let input_string = In_channel.input_all ic in
let actual = Pgn2tex.to_tex input_string ~diagram_data ~clock:false in
let expected =
{|\title{Casual Rapid game}
\author{montillo2015 (1919) vs. reassessyourchess (1869)}
\date{2023.12.03, https://lichess.org/9Z0taHcG}\maketitle
\newchessgame
\textbf{1.} \textbf{d4} \textbf{1...} \textbf{Nf6} \textbf{2.} \textbf{Nf3} \textbf{2...} \textbf{d5} \textbf{3.} \textbf{e3}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:00\par \textbf{3...} \textbf{e6}\par\nobreak 0:10:01\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:01\par \newline D05 Queen's Pawn Game: Colle System\par \textbf{4.} \textbf{a3} \textbf{4...} \textbf{c5} \textbf{5.} \textbf{c4} \textbf{5...} \textbf{Nc6}\par\nobreak 0:10:02\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:02\par \textbf{6.} \textbf{dxc5} \textbf{6...} \textbf{Bxc5} \textbf{7.} \textbf{b4} \textbf{7...} \textbf{Be7} \textbf{8.} \textbf{Bb2}\par\nobreak 0:10:00\par\nobreak\chessboard[setfen=rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 3, vmargin=false]\par\medskip\nobreak\ 0:10:03\par \textbf{8...} \textbf{dxc4} \textbf{9.} \textbf{Qxd8+} \textbf{9...} \textbf{Nxd8} \textbf{10.} \textbf{Bxc4} \textbf{10...} \textbf{O-O} \textbf{11.} \textbf{O-O} \textbf{11...} \textbf{a6} \textbf{12.} \textbf{Nc3} \textbf{12...} \textbf{b5} \textbf{13.} \textbf{Be2} \textbf{13...} \textbf{Bb7} \textbf{14.} \textbf{Nd4} \textbf{14...} \textbf{Ne4} \textbf{15.} \textbf{Nxe4} \textbf{15...} \textbf{Bxe4} \textbf{16.} \textbf{Bf3} \textbf{16...} \textbf{Bxf3} \textbf{17.} \textbf{Nxf3} \textbf{17...} \textbf{Nc6} \textbf{18.} \textbf{Rac1} \textbf{18...} \textbf{Rac8} \textbf{19.} \textbf{Rfd1} \textbf{19...} \textbf{Rfd8} \textbf{20.} \textbf{Rxd8+} \textbf{20...} \textbf{Rxd8} \textbf{21.} \textbf{g3} \textbf{21...} \textbf{Nb8} \textbf{22.} \textbf{Rc7} \textbf{22...} \textbf{Bd6} \textbf{23.} \textbf{Rc2} \textbf{23...} \textbf{f6} \textbf{24.} \textbf{Kg2} \textbf{24...} \textbf{e5} \textbf{25.} \textbf{h4} \textbf{25...} \textbf{e4} \textbf{26.} \textbf{Nd4} \textbf{26...} \textbf{Kf7} \textbf{27.} \textbf{Nf5} \textbf{27...} \textbf{Nd7} \textbf{28.} \textbf{Nxd6+} \newline Black resigns.\par \textbf{1-0}|}
in
ae expected actual;
close_in ic
let suite = let suite =
"pgn2tex tests" "pgn2tex tests"
>::: [ >::: [
"json_str_to_map" >:: test_json_str_to_map; "json_str_to_map" >:: test_json_str_to_map;
"basic_pgn_to_tex" >:: test_basic_pgn_to_tex; "basic_pgn_to_tex" >:: test_basic_pgn_to_tex;
"pgn_with_clock_to_tex" >:: test_pgn_with_clock_to_tex; "pgn_with_clock_to_tex" >:: test_pgn_with_clock_to_tex;
(* "pgn_with_unsupported_text" >:: test_pgn_with_unsupported_text; *)
(* "pgn_with_custom_headers" >:: test_pgn_with_custom_headers; *)
(* "pgn_with_different_unsupported_text"
>:: test_pgn_with_different_unsupported_text; *)
] ]
let () = run_test_tt_main suite let () = run_test_tt_main suite