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

commonmark-ext-gfm-tables single column table #7

Closed
leobuettiker opened this issue Aug 3, 2015 · 6 comments
Closed

commonmark-ext-gfm-tables single column table #7

leobuettiker opened this issue Aug 3, 2015 · 6 comments

Comments

@leobuettiker
Copy link

Would expect to be able to render a single column table. Following code does not render a table.

    final String input = "| First Header |\n" +
            "| ------------- |\n" +
            "| Content Cell |\n" +
            "| Content Cell |\n";
    List<Extension> extensions = Arrays.asList(TablesExtension.create());
    Parser parser = Parser.builder().extensions(extensions).build();
    Node document = parser.parse(input);
    HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build();
    System.out.println(renderer.render(document));
@robinst
Copy link
Collaborator

robinst commented Aug 3, 2015

Confirmed, definitely a bug. Looks like this is the minimal syntax for a single column:

|Header
---

@leobuettiker
Copy link
Author

Unfortunately the specification of the table is not clear for edge cases https://help.github.com/articles/github-flavored-markdown/#tables

As I read the specification your example would be valid (minimal) tables. So would be an example where the vertical bar would be on the right.

@robinst
Copy link
Collaborator

robinst commented Aug 5, 2015

Yeah, it doesn't really have a spec :). But you can try the syntax using the Preview in comments here.

What I'm not happy about with the above example is that in CommonMark, it's a setext header. And extensions should try to avoid changing existing block-level syntax. I'm thinking of requiring at least one pipe for the separator line, e.g. these would be tables:

|Header
|---
Header|
---|

And your original example as well. Thoughts? I have a patch that implements this, I'll push it soon.

robinst added a commit that referenced this issue Aug 8, 2015
Contrary to what GitHub does, the following is not turned into a table:

    |Header
    ---

Because we require the separator line to have at least one pipe in it
(either at the start or the end or between columns). Otherwise it
conflicts with a setext heading. If this turns out to be a problem, we
can always revisit this.
@robinst
Copy link
Collaborator

robinst commented Aug 8, 2015

Fixed as described above. I'll release this soon.

@robinst robinst closed this as completed Aug 8, 2015
@robinst
Copy link
Collaborator

robinst commented Aug 21, 2015

Released in 0.2.0.

@leobuettiker
Copy link
Author

Thanks a lot!

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

No branches or pull requests

2 participants