zestedesavoir / zmarkdown

Live demo: https://zestedesavoir.github.io/zmarkdown/
MIT License
224 stars 52 forks source link

Properly support code-blocks in remark-grid-tables #506

Closed damageboy closed 6 months ago

damageboy commented 7 months ago

Cell contents is not preprocessed to selectively trim whitespace in such a way that leading whitespace inside of a markdown code-block is not trimmed beyond the indentation "set" by the opening of said code-block. Previously all leading whitespace was trimmed, making code-block indentetaion within a table-cell impossible.

StaloneLab commented 7 months ago

I’ll have a proper look later, but at first sight it seems like a very good first PR, thanks! Two minors things I can say for sure: I ran the linter on your code (see Github Actions), and it does not seem to adhere to our rules, especially regarding semicolons, could you please have a look and try to fix it? Also, we still have (although we started dropping it) some transpilation of code for older JS engines, could you run the transpiler using npm run build -- --scope=remark-grid-tables.

If you would like to learn a bit more about the project, to make further contributions for instance, I would also not be against a test for the behavior you’re trying to fix. I am ready to help on the subject should you encounter any problem, but I do not require this test to merge the PR, it will be merged as is if you do not want to work on the project any further.

Finally, it is kind of rare for us to receive PRs from people outside of the project, so may I ask how you encountered this issue? Are you using the ZMarkdown server or our plugins for some kind of project?

damageboy commented 7 months ago

Two minors things I can say for sure: I ran the linter on your code (see Github Actions), and it does not seem to adhere to our rules, especially regarding semicolons, could you please have a look and try to fix it?

I'll fix linting and get GH Actions green, thanks!

I'm trying to use the remark-grid-tables (which are basically restructured text tables AFAICT?) in a docusaurus MDX documentation site since I need the colspan/rowspan feature set as well as actual paragraphs in tables... (code-blocks, lists).

I thought I'd give this remark "plugin" a run, and it performed rather well, which is also how I discovered that it "eats" away important whitespace in code block... hence my attempt at this PR

damageboy commented 7 months ago

Let me know if you get a chance to re-review. In my testing this is ready. If you want me to add many small test cases for these weird edge-cases, just let me know.

StaloneLab commented 7 months ago

I will for sure, I saw your changes yesterday but couldn't review right away. It will be done this week ;)

damageboy commented 6 months ago

Hey, I've done as requested and it looks like I shouldn't have updated the test in the first place.

All test pass locally without any modification now on my local machine (all 1051 snapshots)

damageboy commented 6 months ago

Thanks for all th help and patience with a JS n00b :)

StaloneLab commented 5 months ago

One day late, but I just published a new version including your changes: remark-grid-tables@2.2.1.