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

Adding Support for GFM Tables #74

Merged
merged 4 commits into from
Jan 3, 2013
Merged

Adding Support for GFM Tables #74

merged 4 commits into from
Jan 3, 2013

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Sep 3, 2012

Here is a modified pull request that only adds support for tables that are supported (but undocumented) as part of GFM. It is implemented in the same fashion as other GFM features. It appears to be fully compatible with the Sundown library (which is the markdown parser GFM is based on), though it is strictly based on the PHP Markdown Extra who appears to have introduced the "standard".

The following:

Header 1 | Header 2
-------- | --------
Cell 1   | Cell 2
Cell 3   | Cell 4

Will render as:

Header 1 Header 2
Cell 1 Cell 2
Cell 3 Cell 4

@arikon
Copy link

arikon commented Oct 9, 2012

Any chances that it will be merged?

@bbailes
Copy link

bbailes commented Oct 10, 2012

+1 for merging this into master!

@fengmk2
Copy link

fengmk2 commented Nov 12, 2012

+1 We need this!

@davidsteinberger
Copy link

+1

2 similar comments
@jcla1
Copy link

jcla1 commented Nov 17, 2012

+1

@leeoniya
Copy link

+1

@aleafs
Copy link

aleafs commented Nov 18, 2012

++1

@chjj
Copy link
Member

chjj commented Nov 18, 2012

Will look at this later.

@harrisj
Copy link

harrisj commented Jan 2, 2013

So, is this happening? I'd love it too

@chjj chjj merged commit 832d05c into markedjs:master Jan 3, 2013
@chjj
Copy link
Member

chjj commented Jan 3, 2013

So, I spent a little while fixing/optimizing/refactoring @kitsonk's implementation a little bit. I'm going to consider this feature experimental for a little while. You can disable it with the tables option. @kitsonk, thank you for the PR.

@chjj chjj mentioned this pull request Jan 3, 2013
@harrisj
Copy link

harrisj commented Jan 3, 2013

Awesome. Thank you!

On Jan 3, 2013, at 7:29 AM, "Christopher Jeffrey" <notifications@gh.neting.ccmailto:notifications@github.com> wrote:

So, I spent a little while fixing/optimizing/refactoring @kitsonkhttps://github.com/kitsonk's implementation a little bit. I'm going to consider this feature experimental for a little while. You can disable it with the tables option. @kitsonkhttps://github.com/kitsonk, thank you for the PR.


Reply to this email directly or view it on GitHubhttps://github.com//pull/74#issuecomment-11842143.

@chjj
Copy link
Member

chjj commented Jan 4, 2013

Just a quick test.

testing

paragraph

one two
3 4

testing

testing

paragraph
| one | two |
| ----- | ----- |
| 3    |   4   |

testing

@chjj
Copy link
Member

chjj commented Jan 4, 2013

Once more.

testing

one two
3 4

testing

And one other:

paragraph

var foo = 1;

test

#one two
3 4

strike strike

code: foo
code: ```

@xiaohulu
Copy link

xiaohulu commented Mar 5, 2013

how to escape | in gfm table?

@kitsonk
Copy link
Contributor Author

kitsonk commented Mar 5, 2013

Best thing to do use use the HTML entity: &#124;

@xiaohulu
Copy link

xiaohulu commented Mar 5, 2013

| one | two |
| ----- | ----- |
| 1    |   2 `a|a`   |
| 1    |   2 `a&#124;a`   |

How to escape | in a|a

@kitsonk
Copy link
Contributor Author

kitsonk commented Mar 5, 2013

That appears to be an issue with the sundown parser that GitHub uses as well, so technically it is feature parity:

| one | two |
|-----|-----|
| 1 | 2 `a&#124;a` |
| 1 | a&#124;a |
| 1 | `a|a` |

Renders as:

one two
1 2 a&#124;a
1 a|a
1 `a

@kitsonk
Copy link
Contributor Author

kitsonk commented Mar 5, 2013

Just realised, there is a way around this:

| one |
|-----|
| <code>a&#124;a</code> |

Will render as:

one
a|a

In both marked and sundown.

@hahmed
Copy link

hahmed commented May 1, 2013

Is there any way to actually set the width of a table column?

@kitsonk
Copy link
Contributor Author

kitsonk commented May 1, 2013

Via CSS... :nth-child and other pseudo-selectors address this.

@hahmed
Copy link

hahmed commented May 1, 2013

@kitsonk I mean through markdown so some tables will be rendered bigger or smaller depending on width % set?

I am basically thinking how good this will be for writing documents that have tables in them.

@kitsonk
Copy link
Contributor Author

kitsonk commented May 1, 2013

It isn't part of the standard it is based on, and for good reason. Hard coding presentation in the markup doesn't allow flexibility when it renders. The only potential imrpovement would be to allow the specification of a class for a table, but again, none of the standards out there specify that, so I suspect @chjj wouldn't be interested in adding it, though there are some other issues here that talk about allowing some form of customisation of the output.

You can always use <table> if you need more flexibility.

@bdougie
Copy link

bdougie commented Jul 28, 2015

Anyone else having trouble getting tables to render using marked?

var singleColTest = "| one ||-----|  | <code>a&#124;a</code> |"

app.get('/', function (req, res) {
    // res.send('Hello World!');
    res.send(marked(singleColTest));
});

returns this

| one 
|-----|
| <code>a&#124;a</code> |

ghost pushed a commit to zergeborg/marked that referenced this pull request May 13, 2016
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.