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 = [ var _rules = [
// First 2 params - rule name & source. Secondary array - list of rules, // First 2 params - rule name & source. Secondary array - list of rules,
// which can be terminated by this one. // which can be terminated by this one.
[ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
[ 'code', require('./rules_block/code') ], [ 'code', require('./rules_block/code') ],
[ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
[ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ], [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ],
@ -21,7 +22,6 @@ var _rules = [
[ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ], [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],
[ 'lheading', require('./rules_block/lheading') ], [ 'lheading', require('./rules_block/lheading') ],
[ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ], [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],
[ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
[ 'paragraph', require('./rules_block/paragraph') ] [ '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 | foo
---|--- |----
bar|bar | test2
baz|baz
. .
<ul>
<li>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>foo</th> <th>foo</th>
<th>foo</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>bar</td> <td>test2</td>
<td>bar</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</li>
</ul>
<p>baz|baz</p>
. .
Minimal one-column:
This is parsed as one big table:
. .
| foo - foo|foo
|---- ---|---
| test2 bar|bar
. .
<table> <table>
<thead> <thead>
<tr> <tr>
<th>- foo</th>
<th>foo</th> <th>foo</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>test2</td> <td>bar</td>
<td>bar</td>
</tr> </tr>
</tbody> </tbody>
</table> </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 " ": Second line should not contain symbols except "-", ":", "|" and " ":
. .
foo|foo foo|foo
@ -438,3 +419,26 @@ Heading 1|Heading 2|Heading 3
</tbody> </tbody>
</table> </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