Skip to content

hlotze/pgn2docx

Repository files navigation

pgn2docx

Status

  • The repo is quite stable now, although not in prodution mode - its is more a 'beta', but it works as it should.
  • It will not deal with empty PGN games, i.e. a rated game with not game notation, no pgn, e.g. in case of one oponent will not come to the game, so the other wins the game, without any move played.
    • This is fixed in the next repo pgn2tex, which uses the same mechnism but produces TeX files.

What this site provides

  • a script run_pgn2docx.py that generates one DOCX file from one chess PGN1 match, with a chessboard for each half move, using True Type Font Chess Merida, i.e. 3 full moves / Din A4 page.
    • ensure that you installed the TTF2 Chess Merida, which is given e.g. at TTF/ directory.
    • the script processes all *.pgn files that it find at PGN/ directory.
    • be aware, a PGN file can have thousends of games inside, and with this script each of its games will get a DOCX file in DOCX/ directory
    • each game's DOCX generation take about 1 second (on my old machine.)
    • the script was not possible without python chess and python docx

My intention

... was to support myself learning chess by studying chess games offline form selected PGN printouts. For online studies a good starting point learning chess is lichess.org or others. This approach provides a printout in B/W with more contrast as the colored PDFs at lichess_puzzles_to_pdf.

Steps

  • install the True Type Font (TTF) Chess Merida onto your system; see TTF/; documents created and checked with Windows Microsoft Word (365) and Ubuntu LibreOffice (v6.4.7.2), but actually not possible to install Chess Merida at iPad 😞 so some examples added at DOCX/PDF/*.pdf
    • TTF at Windows: just double-click the file *.ttf and press the Install button
    • TTF at Ubuntu: just the same procedure or see askubuntu
  • check
    • the PGN1 examples; see PGN/
    • the DOCX examples; see DOCX/
    • requirements.txt for the venv
  • run the Python script run_pgn2docx.py

Open item

  • finitalize the project - initially done, it works on some machines :-)
  • add unit tests - initially done, to be completed
  • fix problems with file names
    • if Seven Tag Roster (details at 1) is incomplete, e.g. with older games
    • if Site tag is a web address, e.g. https://lichess.org, as file names can not have a ':' or '/'
  • add the game's ECO3 incl. diagram
  • change eco.csv - no binary format (!) and different eco classification sizes (2k, 10k); see project wiki eco)
  • mark a checked king at the diagrams --> red
  • mark the from- and to-squares of a half move --> lightgreen
  • add [%eval ...] comments 4 to the SAN5 at bottom of a board
  • add
    • venv requirements and pipenv (Pipfile, Pipfile.lock)
    • packageing - is actually a nightmare, will do it later after linting will become better
    • documentation, wiki done
  • evtl. refactor coding to get aligned to python-chess naming conventions and structures

Contact

@hlotze

Footnotes

Footnotes

  1. PGN - see Wikipedia Portable Game Notation 2 3

  2. TTF - see Wikipedia: TrueType

  3. ECO - see Wikipedia: Encyclopaedia of Chess Openings or a Detailed opening library

  4. chess evaluation - see chessprogramming.org/Evaluation

  5. SAN - see Wikipedia: Algebraic_notation_(chess)