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

Syntax proposal for tables #50

Open
mn4367 opened this issue Jan 12, 2014 · 2 comments
Open

Syntax proposal for tables #50

mn4367 opened this issue Jan 12, 2014 · 2 comments

Comments

@mn4367
Copy link

mn4367 commented Jan 12, 2014

Looking at issue #49 it seems that 'correct' column alignment isn't possible with the indicators in the alignment/divider line alone. The following syntax proposal could help. The basic idea is to allow individual cell alignment by using colons in a similar same way they are used in the alignment/divider line:

|    Col A    |    Col B    |    Col C    |
| ----------- | ----------- | ----------- |
|   Cell 1A   |:  Cell 1B  :|   Cell 1C  :|
|:  Cell 2A   |:  Cell 2B               :||

The alignment of Cell 1A is driven by the system as before, Cell 1B is centered, Cell 1C is right aligned, Cell 2A is left aligned and Cell 2B is centered.

|    Col X    |    Col Y    |    Col Z    |
| :---------- | :---------: | ----------: |
|   Cell 1X   |   Cell 1Y   |   Cell 1Z   |
|   Cell 2X  :|:  Cell 2Y   |:  Cell 2Z  :|

The alignment of the cells in the first row is controlled by the alignment/divider line as before, Cell 2X is right aligned, Cell 2YC is left aligned and Cell 2Z is centered.

In general, the following rules should apply:

  1. There must be no space between the pipe and the colon(s) which indicate alignment. If there is a space, the colon is considered to be cell text.
  2. Cell alignment with colons always overrides column alignment driven by the alignment/divider line.
  3. Cell alignment with colons is available for cells in the table header and the table body.
  4. Left or center alignment in the first cell of a row require the use of the pipe at the beginning of the line.
  5. Right or center alignment in the last cell of a row require the use of the pipe at the end of the line.

I know that you are cautious in syntax extensions (for good reasons) but maybe you can consider this extension. Cell alignment is hard to get right with CSS or XSLT after MMD conversion for arbitrary tables.

It is also clear that this extension would break backwards compatibility with (a small amount of) existing documents, so it probably needs to be controllable with a command-line switch or a metadata key.

Thanks,
Michael

@fletcher
Copy link
Owner

I worry that this is starting to get too specific, and not something that most MMD users need.

I'll leave this issue open for now as a reminder to keep thinking about this, but no promises.

Either way, however, I do appreciate your making the suggestion!

F-

@manuel-rubio
Copy link

I'd like to add something to the specification, the possibility to use custom classes:

|    Col X    |    Col Y    |    Col Z    |
| :---------- | :---------: | ----------: |
|   Cell 1X   |   Cell 1Y   |   Cell 1Z   |
|   Cell 2X  :|:  Cell 2Y   |:  Cell 2Z  :|
{:.table}

or even:

{:.table}
|    Col X    |    Col Y    |    Col Z    |
| :---------- | :---------: | ----------: |
|   Cell 1X   |   Cell 1Y   |   Cell 1Z   |
|   Cell 2X  :|:  Cell 2Y   |:  Cell 2Z  :|

to render the table envelop as:

<table class="table"> ... </table>

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

3 participants