3

How do I embed chess games from PGN files in markdown format?

1
  • 2
    Please expand on what you're trying to accomplish or what problem you're encountering.
    – GreenMatt
    Commented Nov 29, 2018 at 16:07

2 Answers 2

2

Well, on this site, you can use the 'replayer'. Basically, you just paste the PGN as a code block; for more details, see Can we implement a replayer for chess analysis on the site?.

For example, the following code will display the first three moves of the Ruy Lopez opening:

    [FEN ""]
    1. e4 e5 2. Nf3 Nc6 3. Bb5

(it doesn't work right here because of the <pre> block in the post source)

But this isn't really converting the PGN into Markdown, it's just Stack Exchange's rendering engine detecting the PGN and converting it into a JavaScript widget. There is no 'official' way of converting PGN into Markdown, just like there is no official way to convert it into HTML.

0

Sometimes when I found interesting articles, I copy it to my notepad2-mod, that allows me some simple syntax highlighting, and that has moved me to adopt the following practices with chess articles with games interspersed.

1) For every pair of moves, supress the dot.

2) To avoid markdown processor interpreting incorrectly the pgn header, place the game between '~~~', before and after the game. This way, the block is treated as a block.

3) Add the text as you please, following the markdown conventions.

For the time being, it is not possible to assign a chess font to the move section, due to the document model followed by markdown. A document, does not change fonts on every paragraph; instead asign fonts to specific parts of the document, like title, tables and text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.