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

Fix tables in a list #1446

Merged
merged 2 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Lexer.prototype.token = function(src, top) {
}

// table no leading pipe (gfm)
if (top && (cap = this.rules.nptable.exec(src))) {
if (cap = this.rules.nptable.exec(src)) {
item = {
type: 'table',
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
Expand Down Expand Up @@ -447,7 +447,7 @@ Lexer.prototype.token = function(src, top) {
}

// table (gfm)
if (top && (cap = this.rules.table.exec(src))) {
if (cap = this.rules.table.exec(src)) {
item = {
type: 'table',
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
Expand Down
44 changes: 44 additions & 0 deletions test/new/list_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<ul>
<li>
<p>Table in list:</p>
<table>
<thead>
<tr>
<th>column1</th>
<th>column2</th>
</tr>
</thead>
<tbody>
<tr>
<td>value1</td>
<td>value2</td>
</tr>
<tr>
<td>value3</td>
<td>value4</td>
</tr>
</tbody>
</table>
</li>
<li>
<p>No leading pipe table in list:</p>
<table>
<thead>
<tr>
<th>column1</th>
<th>column2</th>
</tr>
</thead>
<tbody>
<tr>
<td>value1</td>
<td>value2</td>
</tr>
<tr>
<td>value3</td>
<td>value4</td>
</tr>
</tbody>
</table>
</li>
</ul>
13 changes: 13 additions & 0 deletions test/new/list_table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* Table in list:

| column1 | column2 |
|---------|---------|
| value1 | value2 |
| value3 | value4 |

* No leading pipe table in list:

column1 | column2
--------|--------
value1 | value2
value3 | value4