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

Pipe table parsing deviation #6

Closed
xxxserxxx opened this issue Jun 26, 2024 · 2 comments
Closed

Pipe table parsing deviation #6

xxxserxxx opened this issue Jun 26, 2024 · 2 comments

Comments

@xxxserxxx
Copy link

xxxserxxx commented Jun 26, 2024

godjot's output for pipe tables does not match the reference djot. The issue presents when the table contains multiple headers (which is specifically allowed by the spec).

Here's a small sample to produce the issue:

| XXX, XXXXX          | XXXXXX          | XXXXXX           |
|---------------------|-----------------|------------------|
| XXXXX XXXX          | XXXX-XX XXXX    | XXXXXXXXX, XX    |
| XXXXX XXXXX (X)     | XX:XXXX         | X:XXXX           |
|                     |                 |                  |
| XXX, XXXXX          | XXXXXX          | XXXXXX           |
|---------------------|-----------------|------------------|
| XXXXX XXXX          | XXXXXXXXX, XX   | XXXXXX, XX       |
| XXXXX XXXXXXX+ (X)  | X:XXXX          | XX:XXXX          |
|                     |                 |                  |
| XXX, XXXXX          | XXXXXX          | XXXXXX           |
|---------------------|-----------------|------------------|
| XXXXX XXXX          | XXXXXX, XX      | XXXX-XX XXXX     |
| XXXXX XXXXX (X)     | X:XXXX          | X:XXXX           |

Then to produce the test output:

$ <sample.dj >godjot.html godjot
$ <sample.dj >djot.html djot

and to show the difference, run diff godjot.html djot.html:

13,15c13,20
< <th>XXXXX XXXXX (X)</th>
< <th>XX:XXXX</th>
< <th>X:XXXX</th>
---
> <td>XXXXX XXXXX (X)</td>
> <td>XX:XXXX</td>
> <td>X:XXXX</td>
> </tr>
> <tr>
> <td></td>
> <td></td>
> <td></td>
28,30c33,40
< <th>XXXXX XXXXXXX+ (X)</th>
< <th>X:XXXX</th>
< <th>XX:XXXX</th>
---
> <td>XXXXX XXXXXXX+ (X)</td>
> <td>X:XXXX</td>
> <td>XX:XXXX</td>
> </tr>
> <tr>
> <td></td>
> <td></td>
> <td></td>

The difference is significant, by which I mean it's not simply formatting; the parser produces a completely different AST. Or, maybe the HTML renderer is processing the AST incorrectly -- I haven't yet written a sample program to detect which is happening. But I suspect the parser.

I'm running godjot installed with go install github.com/sivukhin/godjot@latest, which appears to be v1.0.3:

github.com/sivukhin/godjot v1.0.3 h1:ygvKHn+b2vP+lpKYCHT1PCJiSeDJrpJARXmBdWZVCsg=
github.com/sivukhin/godjot v1.0.3/go.mod h1:wA6KdR4Z+XpwdwyViPDLWYYxT72pKjNc6XGA9I025gM=

And compiled with go1.22.4 linux/amd64

sivukhin added a commit that referenced this issue Jun 26, 2024
sivukhin added a commit that referenced this issue Jun 26, 2024
Fix detection of separator lines:
1. Always check that at least one dash is present
2. Analyze whole content between pipes including white spaces
@sivukhin
Copy link
Owner

Hi @xxxserxxx! Thanks for the great sample to reproduce the bug!

The issue were in the pipe separators detection logic. I already fixed it in the PR #7 and published [email protected] which should resolve your issue.

Now, godjot produce exactly the same output as original djot implementation on your example.

@xxxserxxx
Copy link
Author

xxxserxxx commented Jun 26, 2024

Beautiful. Thanks for the quick response! Oh, and confirmed.

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

No branches or pull requests

2 participants