Documentation: Using pgn-parser in the Browser
Bebul opened this issue · 1 comments
I had hard time to make the library possible to use in the client side application, Browser.
The successfull steps were at last:
- install Browserify
- store the
parse
function aswindow
property
File:parsePgn.js
const parser = require('./pgn-parser.js')
window.parsePgn = parser.parse
- process newly created
parsePgn.js
through Browserify:
browserify parsePgn.js -o pgn-bundle.js
- in the
index.html
then use
<script type="text/javascript" src="pgn/pgn-bundle.js"></script>
- and the parsePgn is now available:
let gameList = parsePgn('[White "Me"] [Black "Magnus"] 1. f4 e5 2. g4 Qh4#', {startRule: "game"});
Thank you a lot for documenting that tedious process in a ticket. The reason that there is no documentation at all about that is, that I am using the library only as part of PgnViewerJS, which in itself has a build process that ensures that the whole thing runs in a browser. I am not at all an expert in Javascript and the best way to bring libraries to the browser, I would not have suspected that someone is interested in this.
I will take your ticket as a reminder, that there may be different ways to use the library, and check the (sparse) documentation, and hopefully improve it then later. Thank you!