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

Format table #174

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Format table #174

wants to merge 3 commits into from

Conversation

m1bcodes
Copy link

Hello Mads

I have started an automatic table formatting function. Below is a description, how it works. If you think it is useful for others and would be interested in pulling it in, please let me know. Then i will clean it up according to your contribution guidelines.

Best regards,
Michael

Automatic table formatting

Markdown Editor supports table preview, but layouting them manually in the
text editor is a cumbersome endeavour. But there exists an automatic table
formatting function, which makes the tables look nice in the plain text
view and and allows easy formatting after you typed the contents.
Also reformatting an existing table is no problem.

Select the source code, which belongs to the table and choose "Format table"
from the context menu:
Format Table

The markdown language supports two types of tables:

Pipe Tables:

They are one line of text per row and the columns are stretched to
accomodate the text. Using automatic table formatting you can simply
type the table entries without having to care about the appearance:

Header 1|Header 2|Header 3
row 1 col 1|row 1 col 2|row 1 col 3 and some more text

After formatting the table, the source code looks like this

Header 1   |Header 2   |Header 3                      
-----------|-----------|------------------------------
row 1 col 1|row 1 col 2|row 1 col 3 and some more text

And here is the rendered version of the table:

Header 1 Header 2 Header 3
row 1 col 1 row 1 col 2 row 1 col 3 and some more text

Grid tables:

Grid tables allow more than one line of text which is word wrapped
to fit into the specified column width.
The column width are specified by the first separator line and again
it is not necessary to care about the layout while typing. Just indicate
column boundaries by a pipe '|', and a row boundaries by a line starting
with '+'.

+---------------+-------------+-------------------+
Header 1   |Header 2   |Header 3                      
row 1 col 1|row 1 col 2|row 1 col 3 and some more text
+
Header 1   |Header 2   |Header 3                      
row 1 col 1|row 1 col 2|row 1 col 3 and some more text
+

After formatting:

+---------------+-------------+-------------------+
| Header 1 row  | Header 2    | Header 3 row 1    |
|1 col 1        |row 1 col 2  |col 3 and some     |
|               |             |more text          |
+---------------+-------------+-------------------+
| Header 1 row  | Header 2    | Header 3 row 1    |
|1 col 1        |row 1 col 2  |col 3 and some     |
|               |             |more text          |
+---------------+-------------+-------------------+

And the rendered version:

...not rendered by github...

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

Successfully merging this pull request may close these issues.

1 participant