Skip to content

Commit

Permalink
Merge pull request markedjs#1446 from UziTech/list-table
Browse files Browse the repository at this point in the history
Fix tables in a list
  • Loading branch information
UziTech committed Mar 12, 2019
2 parents 5e47c5f + b6434e2 commit be213f2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
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

0 comments on commit be213f2

Please sign in to comment.