fix(tables): pipe char can now be escaped

Pipe character is now treated as a special markdown char,
which makes it possible to escape it.

Closes #345
This commit is contained in:
Estevao Soares dos Santos 2017-02-21 14:13:12 +00:00
parent 5d40c7a0ee
commit 1ebc1959dd
11 changed files with 45 additions and 2 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

@ -14,7 +14,7 @@ showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
text = text.replace(/\\([`*_{}\[\]()>#+.!~=-])/g, showdown.helper.escapeCharactersCallback);
text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
return text;

View File

@ -13,7 +13,7 @@ showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, opti
text = text.replace(regex, function (wholeMatch) {
return wholeMatch
.replace(/(.)<\/?code>(?=.)/g, '$1`')
.replace(/([\\`*_~=])/g, showdown.helper.escapeCharactersCallback);
.replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
});
text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);

View File

@ -57,6 +57,10 @@ showdown.subParser('tables', function (text, options, globals) {
text = globals.converter._dispatch('tables.before', text, options, globals);
// find escaped pipe characters
text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
// parse tables
text = text.replace(tableRgx, function (rawTable) {
var i, tableLines = rawTable.split('\n');

View File

@ -0,0 +1,30 @@
<table>
<thead>
<tr>
<th>Operator</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>&amp;</td>
<td>Logical AND</td>
</tr>
<tr>
<td>&amp;&amp;</td>
<td>Shortcut AND</td>
</tr>
<tr>
<td>|</td>
<td>Logical OR</td>
</tr>
<tr>
<td>||</td>
<td>Shortcut OR</td>
</tr>
<tr>
<td>^</td>
<td>Logical XOR</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,7 @@
| Operator | Description |
|----------|-------------|
| & | Logical AND |
| && | Shortcut AND |
| \| | Logical OR |
| \|\| | Shortcut OR |
| ^ | Logical XOR |

View File

@ -0,0 +1 @@
<p>this |</p>

View File

@ -0,0 +1 @@
this \|