commit
05e322c69b
@ -1340,7 +1340,22 @@ function merge(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function splitCells(tableRow, count) {
|
function splitCells(tableRow, count) {
|
||||||
var cells = tableRow.replace(/([^\\])\|/g, '$1 |').split(/ +\| */),
|
// ensure that every cell-delimiting pipe has a space
|
||||||
|
// before it to distinguish it from an escaped pipe
|
||||||
|
var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
||||||
|
var escaped = false,
|
||||||
|
curr = offset;
|
||||||
|
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
||||||
|
if (escaped) {
|
||||||
|
// odd number of slashes means | is escaped
|
||||||
|
// so we leave it alone
|
||||||
|
return '|';
|
||||||
|
} else {
|
||||||
|
// add space before unescaped |
|
||||||
|
return ' |';
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
cells = row.split(/ \|/),
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (cells.length > count) {
|
if (cells.length > count) {
|
||||||
@ -1350,7 +1365,8 @@ function splitCells(tableRow, count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; i < cells.length; i++) {
|
for (; i < cells.length; i++) {
|
||||||
cells[i] = cells[i].replace(/\\\|/g, '|');
|
// leading or trailing whitespace is ignored per the gfm spec
|
||||||
|
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
||||||
}
|
}
|
||||||
return cells;
|
return cells;
|
||||||
}
|
}
|
||||||
|
@ -46,3 +46,18 @@ describe('Marked Code spans', function() {
|
|||||||
messenger.test(spec, section, ignore);
|
messenger.test(spec, section, ignore);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Marked Table cells', function() {
|
||||||
|
var section = 'Table cells';
|
||||||
|
|
||||||
|
// var shouldPassButFails = [];
|
||||||
|
var shouldPassButFails = [];
|
||||||
|
|
||||||
|
var willNotBeAttemptedByCoreTeam = [];
|
||||||
|
|
||||||
|
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
|
||||||
|
|
||||||
|
markedSpec.forEach(function(spec) {
|
||||||
|
messenger.test(spec, section, ignore);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -2,7 +2,55 @@
|
|||||||
{
|
{
|
||||||
"section": "Code spans",
|
"section": "Code spans",
|
||||||
"markdown": "`someone@example.com`",
|
"markdown": "`someone@example.com`",
|
||||||
"html": "<p><code>someone@exmaple.com</code></p>\n",
|
"html": "<p><code>someone@example.com</code></p>",
|
||||||
"example": 1
|
"example": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|\n|-|\n|1|",
|
||||||
|
"html": "<table><thead><tr><th>1</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table>",
|
||||||
|
"example": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|\n|-|\n|\\||",
|
||||||
|
"html": "<table><thead><tr><th>1</th></tr></thead><tbody><tr><td>|</td></tr></tbody></table>",
|
||||||
|
"example": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|\n|-|\n|1\\\\1|",
|
||||||
|
"html": "<table><thead><tr><th>1</th></tr></thead><tbody><tr><td>1\\1</td></tr></tbody></table>",
|
||||||
|
"example": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|\n|-|\n|\\\\\\\\||",
|
||||||
|
"html": "<table><thead><tr><th>1</th></tr></thead><tbody><tr><td>\\\\</td></tr></tbody></table>",
|
||||||
|
"example": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|\n|-|\n|\\\\\\\\\\||",
|
||||||
|
"html": "<table><thead><tr><th>1</th></tr></thead><tbody><tr><td>\\\\|</td></tr></tbody></table>",
|
||||||
|
"example": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|2|\n|-|-|\n||2|",
|
||||||
|
"html": "<table><thead><tr><th>1</th><th>2</th></tr></thead><tbody><tr><td></td><td>2</td></tr></tbody></table>",
|
||||||
|
"example": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|2|\n|-|-|\n|1\\|\\\\|2\\|\\\\|",
|
||||||
|
"html": "<table><thead><tr><th>1</th><th>2</th></tr></thead><tbody><tr><td>1|\\</td><td>2|\\</td></tr></tbody></table>",
|
||||||
|
"example": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": "Table cells",
|
||||||
|
"markdown": "|1|2|\n|-|-|\n| |2|",
|
||||||
|
"html": "<table><thead><tr><th>1</th><th>2</th></tr></thead><tbody><tr><td></td><td>2</td></tr></tbody></table>",
|
||||||
|
"example": 9
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user