Browse Source

Bump table priority before code blocks

ref https://github.com/markdown-it/markdown-it/issues/120
pull/165/head
Alex Kocharin 9 years ago
parent
commit
0318337a3d
  1. 2
      lib/parser_block.js
  2. 68
      test/fixtures/markdown-it/tables.txt

2
lib/parser_block.js

@ -12,6 +12,7 @@ var Ruler = require('./ruler');
var _rules = [
// First 2 params - rule name & source. Secondary array - list of rules,
// which can be terminated by this one.
[ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
[ 'code', require('./rules_block/code') ],
[ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
[ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ],
@ -21,7 +22,6 @@ var _rules = [
[ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],
[ 'lheading', require('./rules_block/lheading') ],
[ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],
[ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
[ 'paragraph', require('./rules_block/paragraph') ]
];

68
test/fixtures/markdown-it/tables.txt

@ -121,69 +121,50 @@ baz|baz
.
Nested tables inside lists:
Minimal one-column:
.
- foo|foo
---|---
bar|bar
baz|baz
| foo
|----
| test2
.
<ul>
<li>
<table>
<thead>
<tr>
<th>foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>bar</td>
<td>test2</td>
</tr>
</tbody>
</table>
</li>
</ul>
<p>baz|baz</p>
.
Minimal one-column:
This is parsed as one big table:
.
| foo
|----
| test2
- foo|foo
---|---
bar|bar
.
<table>
<thead>
<tr>
<th>- foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>test2</td>
<td>bar</td>
<td>bar</td>
</tr>
</tbody>
</table>
.
Second line indent should not be smaller than first:
.
- foo|foo
---|---
bar|bar
.
<ul>
<li>foo|foo
—|---
bar|bar</li>
</ul>
.
Second line should not contain symbols except "-", ":", "|" and " ":
.
foo|foo
@ -438,3 +419,26 @@ Heading 1|Heading 2|Heading 3
</tbody>
</table>
.
Should be parsed before code blocks:
.
foo | bar
----- | -----
aaa | bbb
.
<table>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>aaa</td>
<td>bbb</td>
</tr>
</tbody>
</table>
.

Loading…
Cancel
Save