fix(tables): pipe character in code spans no longer breaks table

A code span with a pipe character no longer incorrectly breaks the cell table.

Closes #465
This commit is contained in:
Estevao Soares dos Santos 2017-11-23 05:39:53 +00:00
parent f4f63c5c39
commit 0c933a01f9
7 changed files with 20 additions and 1 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -61,14 +61,16 @@ showdown.subParser('tables', function (text, options, globals) {
function parseTable (rawTable) {
var i, tableLines = rawTable.split('\n');
// strip wrong first and last column if wrapped tables are used
for (i = 0; i < tableLines.length; ++i) {
// strip wrong first and last column if wrapped tables are used
if (/^ {0,3}\|/.test(tableLines[i])) {
tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
}
if (/\|[ \t]*$/.test(tableLines[i])) {
tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
}
// parse code spans first, but we only support one line code spans
tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
}
var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),

View File

@ -0,0 +1,14 @@
<table>
<thead>
<tr>
<th>PowerShell command</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>Get-Service</td>
<td><code>Get-Service | Stop-Service -WhatIf</code></td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,3 @@
|PowerShell command|Example|
|--|--|
|Get-Service|`Get-Service | Stop-Service -WhatIf`|