Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Using pgn-parser in the Browser #22

Closed
Bebul opened this issue Nov 4, 2020 · 1 comment
Closed

Documentation: Using pgn-parser in the Browser #22

Bebul opened this issue Nov 4, 2020 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Bebul
Copy link

Bebul commented Nov 4, 2020

I had hard time to make the library possible to use in the client side application, Browser.

The successfull steps were at last:

  1. install Browserify
  2. store the parse function as window property
    File: parsePgn.js
   const parser =  require('./pgn-parser.js')
   window.parsePgn = parser.parse
  1. process newly created parsePgn.js through Browserify:
 browserify parsePgn.js -o pgn-bundle.js
  1. in the index.html then use
 <script type="text/javascript" src="pgn/pgn-bundle.js"></script>
  1. and the parsePgn is now available:
     let gameList = parsePgn('[White "Me"] [Black "Magnus"] 1. f4 e5 2. g4 Qh4#', {startRule: "game"});
@mliebelt
Copy link
Owner

mliebelt commented Nov 7, 2020

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!

@mliebelt mliebelt self-assigned this Nov 7, 2020
@mliebelt mliebelt added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 7, 2020
@mliebelt mliebelt closed this as completed Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants