Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Please support reduced table syntax #20

Open
cmrd-senya opened this issue Jun 8, 2018 · 5 comments
Open

Please support reduced table syntax #20

cmrd-senya opened this issue Jun 8, 2018 · 5 comments

Comments

@cmrd-senya
Copy link

cmrd-senya commented Jun 8, 2018

The following is correct syntax for a markdown table:

Head1|Head2
-|-
12312321|24234324

If you put this on github it will be rendered properly:

Head1 Head2
12312321 24234324

However it seems like this is not recognized by the plugin. Can you please support the syntax too?

@susisu
Copy link
Owner

susisu commented Jun 9, 2018

Hi, thanks for you suggestion!

Such reduced syntax is currently not supported since it becomes unclear whether a given text is a table or not.

Is the following line is a table header or not?
From syntax point of view, this should be a table header, but from UI point of view, it should not.

The vertical bar | is sometimes called "pipe".

Is the following line is a table header or a list item?
It is completely ambiguous since there are no standard Markdown spec.

+ The vertical bar | is sometimes called "pipe".

With leading pipes, it is much clear for both parsers and users to recognize.

Actually I sometimes use the reduced syntax when I have trouble with typing many pipes, but with this package I have no trouble 😄

@cmrd-senya
Copy link
Author

Well, I rely on what GitHub treats as a table. Is it possible to make this syntax work when grammar is set to GitHub Markdown? It feels consistent this way, because this grammar defines the markdown spec somehow.

@susisu
Copy link
Owner

susisu commented Jun 10, 2018

Is it possible to make this syntax work when grammar is set to GitHub Markdown?

Good idea!
But, as I wrote above, the problem is not only the syntax but the ambiguity of behavior.

Suppose you have one of the following lines, and the cursor is in it.
What behavior do you expect when you hit enter?

The vertical bar | is sometimes called "pipe".
name | description
`let cond = foo || bar`

Should it be formatted as a table? or should the editor simply insert a newline character?

The last one is both a valid code span and a valid table row with three cells (!) according to the GitHub Flavored Markdown Spec.
Indeed,

`let cond = foo || bar`
-|-|-

yields the following table:

`let cond = foo bar`

@cmrd-senya
Copy link
Author

cmrd-senya commented Jun 10, 2018

What I'm more concerned about is not the autocomplete behavior when I hit enter, but rather the automatic reformat when I save the file.

If it was possible I think it is optimal to not autocomplete let cond = foo || bar as a table, but at the same time apply the formatting to

`let cond = foo || bar`
-|-|-

on the file save automatically. GitHub renders it as a table anyway, so it's fine if we do. But let cond = foo || bar is ambiguous as table header, so we just don't do anything about it for autocomplete. But

`let cond = foo || bar`
-|-|-

can be viewed as a non-ambigous table, because there are few reasons to put -|-|- after a line unless you want a table.

My usecase is that I have files with reduced syntax used and I want them to be reformatted. But I'm okay with that it doesn't autocomplete the table when I just write the reduced header something | something else.

What do you think?

@susisu
Copy link
Owner

susisu commented Jun 10, 2018

OK, I understand your use case 👍
And now I am positively thinking to support that syntax.

Since I made this package mainly focusing on creating tables from scratch, formatting already existing tables has not been considered very much.

The current code is specialized for only one syntax, and supporting other syntax will be a bit challenging task.
It may take for a while, so please wait...

Thank you for the discussion!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants