philipparndt / vscode-markdown-tables

MIT License
4 stars 0 forks source link

reStructuredText support #62

Open jessicah opened 3 years ago

jessicah commented 3 years ago

Hi,

I added the basics of reStructuredText to my fork of the upstream repo (parsing and stringifying), which works relatively okay, then came across your updated fork.

One of the issues I'm having, that Im not sure if it applies in markdown tables is having linebreaks within a cell.

Does your extension support cells with multiple lines, essentially a paragraph?

An example of a reStructuredText table I have:

+------------------------------------+---------------------------------------+
| Constant                           | Description                           |
+====================================+=======================================+
| :cpp:enum:`B_INPUT_METHOD_STARTED` | Tells your view that a new inputn     |
|                                    | has begun. Inside the message is a    |
|                                    | :cpp:class:`BMessenger` named be:rept |
|                                    | you should store this because it's y  |
|                                    | way of talking to the input method we |
|                                    | transaction is going on               |
+------------------------------------+---------------------------------------+
| :cpp:enum:`B_INPUT_METHOD_STOPPED` | Lets you know he transaction is over; |
|                                    | should discard the :cpp:class:`BMesse |
|                                    | this point because it's gone stale.   |
+------------------------------------+---------------------------------------+

I'm mostly concerned around auto-formatting a table, as the reStructuredText format is quite strict, and having some niggling issues with the original repo implementation, so am considering using your fork as an updated base, if there's a chance it will make this part easier...

philipparndt commented 3 years ago

Hi,

multi-line cells in markdown tables are only supported using \n so not exactly what you are looking for. I already started thinking about how to implement support for reStructuredText, but in my opinion, it will not get an easy task. The main challenge will be that it is necessary to track each and every change made by the user to make the decisions during auto format. And even this is not always enough as the user can always paste some text.

Example - Given the following table:

+---------------+-------+
| Col A | Col B | Col C |
+=======+=======+=======+
| joined cells  |       |
+---------------+-------+

When the user makes the following change:

+---------------+-------+
| Col A | Col B | Col C |
+=======+=======+=======+
| joined cells  |    |   |
+---------------+-------+

it is unclear how to format the table. It could be that Col A and Col B are joined and Col C is split, but it could also be that they are just three regular cells or we even like to create Col D. Maybe we would need some additional logic to keep cells, that are perfectly aligned for example, but it might also be the wrong guess in some cases.

However, I do not see an issue with implementing just the multi-line support without support for splitting and joining columns. Switching to EBNF instead of the manual parser was definitely the right decision, as it was an enabler for more complex parsing features like escaping. So I suggest that you should use this or implement it in your solution as well.

I would be happy to use a great reStructuredText support on some projects as well :smile: