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

Update PBN parser to fix comment separation #7

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Kaukov
Copy link

@Kaukov Kaukov commented Apr 23, 2019

Currently, when a multi-line comment starting with { and
immediately followed by content, but the content ends a few lines below,
OR a comment that is part of the data, is not parsed properly.

Currently, when a multi-line comment starting with { and
immediately followed by content, but the content ends a few lines below,
OR a comment that is part of the data, is not parsed properly.

This commit fixes this issue and the document is parsed properly.
@coveralls
Copy link

coveralls commented Apr 23, 2019

Coverage Status

Coverage decreased (-0.3%) to 98.784% when pulling 23370bf on Kaukov:master into cc2928f on richardschneider:master.

This allows installation directly from GitHub through npm/yarn
@richardschneider
Copy link
Owner

Thank you for the PR. The code looks good.

Could you add a test that checks what is being fixed, take a look at this test

@Kaukov
Copy link
Author

Kaukov commented Apr 25, 2019

Yes, I'll add a test after work today.

Some comments appear inside tag sections and need to be
parsed as comments while retaining the tag section and tokens.
@Kaukov
Copy link
Author

Kaukov commented Jun 12, 2019

I'm very sorry for the delay, but I had zero time to look at the issue.
Now I've hackfixed it and I'm not satisfied with the code, but it works.

Have you thought on refactoring the transform function?

test/pbn.js Outdated
@@ -367,13 +367,13 @@ describe('PBN', () => {

it('should have multiple lines with braces', (done) => {
let comment = {};
text('{\r\nline 1\r\nline 2\r\n}')
text('{\r\nline 1\r\nline 2\r\n\}')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are the same. So why should the test change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my, I don't know how the \ got in there. I'll remove it when I make other changes

test/pbn.js Outdated
.pipe(pbn())
.on('error', done)
.on('data', data => { comment = data; })
.on('end', () => {
comment.should.have.property('type', 'comment');
comment.should.have.property('text', 'line 1\r\nline 2\r\n');
comment.should.have.property('text', 'line 1\r\nline 2\r\n\r\n');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have broken a test, not a good idea.

@richardschneider
Copy link
Owner

Let's go back basics. What PBN files are failing. We should have a test for each PBN file.

Give me a link or attach them to a comment, so that I can look at them.

I appreciate the work you are doing.

@Kaukov
Copy link
Author

Kaukov commented Jun 13, 2019

I cannot give you the whole results file, but I can give you an excerpt of it.

In the first code, one of the comments breaks the whole file when using the master branch.
And in the second code, the last auction line doesn't get parsed at all, again when using the master branch.

I've hackfixed both situations and my fork parses the file properly. I know it's not a proper solution, but I wanted to have a somewhat working example because of a rush.
Now that I have given you the examples, I would love to know what you think and what you can do about it.

Thanks!

%TSTCustomSortOrder Default
%TSTReport List
%TSTReportOrder ByNumber
%TSTReportShade Yes
%SelectedBoard 7
{IP=1.1.1.1
Play with Someone}
[Event ""]
[Site ""]
[Date "10/10/2010 10:10:10"]
[Board "1"]
[West ""]
[North ""]
{Game duration: 00:04:30}
[East ""]
[South ""]
[Dealer "N"]
[Vulnerable "None"]
[Deal "N:92.9.T654.QT9532 J3.AT7.9872.K876 KQ8765.543.AKQ.A AT4.KQJ862.J3.J4"]
{PAR of the deal: 3H  = played by East : 140 points
Feasability: 7 6 4 5 5 6 6 9 8 8 7 6 4 5 5 6 6 9 8 8 }
[Scoring ""]
[Declarer ""]
[Contract ""]
[Result ""]
[BCFlags "7f"]
[Score ""]

And here's only 1 tag of another game:

[Auction "E"]
Pass Pass Pass 2D
Pass 2H Pass 2S
Pass 2NT Pass 3C
Pass 3S Pass 4S
Pass Pass Pass {two-way auction}

zdraganov pushed a commit to zdraganov/pbn that referenced this pull request Oct 22, 2019
…er-pr

Refactor a bit and add tests for richardschneider#7 of richardschneider/pbn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants