mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
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:
parent
5d40c7a0ee
commit
1ebc1959dd
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
30
test/features/tables/#345.escape-pipe-character.html
Normal file
30
test/features/tables/#345.escape-pipe-character.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Operator</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>&</td>
|
||||
<td>Logical AND</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>&&</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>
|
7
test/features/tables/#345.escape-pipe-character.md
Normal file
7
test/features/tables/#345.escape-pipe-character.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
| Operator | Description |
|
||||
|----------|-------------|
|
||||
| & | Logical AND |
|
||||
| && | Shortcut AND |
|
||||
| \| | Logical OR |
|
||||
| \|\| | Shortcut OR |
|
||||
| ^ | Logical XOR |
|
1
test/issues/#345.no-escape-for-the-pipe-character.html
Normal file
1
test/issues/#345.no-escape-for-the-pipe-character.html
Normal file
|
@ -0,0 +1 @@
|
|||
<p>this |</p>
|
1
test/issues/#345.no-escape-for-the-pipe-character.md
Normal file
1
test/issues/#345.no-escape-for-the-pipe-character.md
Normal file
|
@ -0,0 +1 @@
|
|||
this \|
|
Loading…
Reference in New Issue
Block a user