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

Unexpected behaviour on mixing tables and inline code #465

Closed
StaloneLab opened this issue Jan 29, 2020 · 1 comment
Closed

Unexpected behaviour on mixing tables and inline code #465

StaloneLab opened this issue Jan 29, 2020 · 1 comment

Comments

@StaloneLab
Copy link

@StaloneLab StaloneLab commented Jan 29, 2020

Subject of the issue

The current table serializer has a problem when the length of one line doesn't match the length of the header line.
See the example under, which gives a failing case when putting a markdown table code inside an inline code inside a table.

Your environment

  • OS: Using latest Linux kernel, Arch Linux
  • Packages: remark-parse 7.0.2
  • Env: Node 13.6, NPM 6.13.6

I think the problem does affect every environment.

Steps to reproduce

Copy the following code, which is the default one given on the README:

const vfile = require('to-vfile')
const unified = require('unified')
const markdown = require('remark-parse')
const remark2rehype = require('remark-rehype')
const stringify = require('rehype-stringify')

unified()
  .use(markdown)
  .use(remark2rehype)
  .use(stringify)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Using the following Markdown inside example.md:

Title 1 | Title 2
--------|--------
`this is good`| `left | right`

Expected behaviour

I expect the second column of the second line to be left | right, i.e., the following code:

<table>
<thead>
<tr>
<th>Title 1</th>
<th>Title 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>this is good</code></td>
<td><code>left|right</code></td>
</tr>
</tbody>
</table>

Actual behaviour

The current behaviour is quite weird, and parses the table first, discarding a "third column" it thinks exist:

<table>
<thead>
<tr>
<th>Title 1</th>
<th>Title 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>this is good</code></td>
<td>`left</td>
</tr>
</tbody>
</table>
@wooorm
Copy link
Member

@wooorm wooorm commented Jan 29, 2020

Hi there! 👋 Welcome!

While I understand your confusion, the current behaviour is the correct behaviour. It’s the same on GitHub:

Title 1 Title 2
this is good `left

More information can be found in the PR: #420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants