Fix table cells#1262
Conversation
| return ' |'; | ||
| } | ||
| }), | ||
| cells = row.split(/ \|/), |
There was a problem hiding this comment.
I originally had a very complex replace regex but I couldn't get it to not be vulnerable to catastrophic backtracking, but this works
There was a problem hiding this comment.
I prefer code to complex regexes anyway :-)
test/specs/marked/marked.json
Outdated
| "section": "Code spans", | ||
| "markdown": "`someone@example.com`", | ||
| "html": "<p><code>someone@exmaple.com</code></p>\n", | ||
| "html": "<p><code>someone@exmaple.com</code></p>", |
There was a problem hiding this comment.
Nit, and looks like a holdover, but "exmaple" -> "example" ?
| "html": "<p><code>someone@exmaple.com</code></p>", | ||
| "example": 1 | ||
| }, | ||
| { |
There was a problem hiding this comment.
Nice set of tests. Could you add one or two really simple ones, e.g.
|1||1\|||1\\1|
Starting simple makes the later ones easier to understand.
There was a problem hiding this comment.
Still no example with a singly-escaped pipe? \|
|
|
||
| function splitCells(tableRow, count) { | ||
| var cells = tableRow.replace(/([^\\])\|/g, '$1 |').split(/ +\| */), | ||
| var row = tableRow.replace(/\|/g, function (match, offset, str) { |
There was a problem hiding this comment.
Can you add a comment above this line/function explaining its purpose? (It looks like the goal is to ensure that every cell-delimiting pipe has a space before it, so that you can split cells on ' |').
|
|
||
| for (; i < cells.length; i++) { | ||
| cells[i] = cells[i].replace(/\\\|/g, '|'); | ||
| cells[i] = cells[i].trim().replace(/\\\|/g, '|'); |
There was a problem hiding this comment.
Worth noting in a comment that leading or trailing whitespace is ignored per the spec.
davisjam
left a comment
There was a problem hiding this comment.
Looks good overall, a few nits here and there.
|
|
|
|
Fix table cells
Marked version: master
Markdown flavor: Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
Description
|fixes #1290
Contributor
Committer
In most cases, this should be a different person than the contributor.