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

remark-grid-tables does not work with latest version of remark #465

Closed
dwjohnston opened this issue Jul 4, 2022 · 8 comments
Closed

remark-grid-tables does not work with latest version of remark #465

dwjohnston opened this issue Jul 4, 2022 · 8 comments
Labels
semver/bugfix This is a minor backward-compatible fix status/duplicate This is "déjà vu" type/request This is great to have

Comments

@dwjohnston
Copy link

I suspect that a later release of remark has broken remark-grid-table.

You can see here on Remark's list of plugins that remark-grid-tables is showing as broken:

https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins

I have a repro attempting basic usage of the plugin here:

https://github.com/dwjohnston/remark-play/tree/851e343e3bf969b371c7737a9a93ea3751384962

When we run this we get:

/Users/davidjohnston/git/remark-play/node_modules/remark-grid-tables/dist/index.js:869
  var blockTokenizers = Parser.prototype.blockTokenizers;
                                         ^

TypeError: Cannot read properties of undefined (reading 'blockTokenizers')

That is - I believe that the Parser object is no longer attached.

@dwjohnston
Copy link
Author

Can confirm this works for older version of unified, remark etc.

https://github.com/dwjohnston/remark-play/tree/d6de4d8cde062e767a0d19b84675b50c9f88ca90

Can I suggest adding those values as peer deps?

@dwjohnston dwjohnston changed the title remark-grid-tables does not work with remark remark-grid-tables does not work with latest version of remark Jul 4, 2022
@dwjohnston
Copy link
Author

By upgrading the dependencies one at a time, I'm able to ascertain that it is the upgrade of 8.x.x to 10.x.x of remark-parse that causes the breaking issue.

dwjohnston/remark-play@8825694

@dwjohnston
Copy link
Author

I'm having a little bit of trouble reading the remark change log, but for remark-parse 9 and 10:

https://github.com/remarkjs/remark/releases/tag/remark-parse%409.0.0

refers to major release 13 of remark:

https://github.com/remarkjs/remark/releases/tag/13.0.0

And remark-parse 10 refers to major release 14 of remark

https://github.com/remarkjs/remark/releases/tag/14.0.2
remarkjs/remark@14.0.1...14.0.2

however 14 seems like it is just documentation fixes?

@dwjohnston
Copy link
Author

dwjohnston commented Jul 4, 2022

Some related issues:

remarkjs/remark#499
remarkjs/remark#357 Issue from before remark@13
remarkjs/remark#453 Issue from before remark@13

Is it that blockTokenizers hasn't been removed, but that another plugin removes it?

@dwjohnston
Copy link
Author

Related issue here: #416

@StaloneLab
Copy link
Member

Hello 👋

this issue is known, as you have noticed. Especially, the README states:

Currently, all the plugins provided only work for remark versions lesser than 13.0.0 (i.e. previous to micromark).

To make it short, migration of the plugins is planned, but without any milestone. I have very little time to work on it so it is unlikely to be done anytime soon, especillay for remark-grid-tables which is a big package.

At first sight, it seems to me to be a good idea adding remark <13 as peer dependency. I need to think about it but I will see what can be done. I'm keeping this issue open as a reminder, but further questions about the migration to micromark should go on #416 .

@StaloneLab StaloneLab added status/duplicate This is "déjà vu" type/request This is great to have semver/bugfix This is a minor backward-compatible fix status/verified This has been checked by a maintainer labels Jul 5, 2022
@dwjohnston
Copy link
Author

dwjohnston commented Jul 7, 2022

@StaloneLab No worries, thanks for replying.

For anyone who needs it, my current workaround is to convert the grid table into a gfm style table.

function transformGridTableToGfmFn(input) {
  // TIL - JavaScript needs the multiline flag
  // To work over for end of line matching
  // https://javascript.info/regexp-multiline-mode

  // Note - distinction between $ and \n in the regex.
  // If you want to get replace the linebreak itself, then use \n

  // Remove +---+ lines 
  const mdValue2 = input.replace(/^\+[-+]*\+\s*\n/gm, '');
  
  // Convert +===+ lines to |---| lines (this is the line between the table header and the table body)
  const mdValue3 = mdValue2.replace(/=+\+\s*$/gm, '=|');
  const mdValue4 = mdValue3.replace(/\+=+/gm, '|---');

  return mdValue4;
}

@StaloneLab
Copy link
Member

Thanks for this workaround. It only works for simple tables unfortunately, I think, so the scope seems limited, but it might be helpful if someone is interested in the syntax.

@StaloneLab StaloneLab removed the status/verified This has been checked by a maintainer label Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/bugfix This is a minor backward-compatible fix status/duplicate This is "déjà vu" type/request This is great to have
Projects
None yet
Development

No branches or pull requests

2 participants