mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(table): tables with a preceding footnote are now rendered correctly
This commit is contained in:
parent
e4c87cf5d5
commit
6c76e79453
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.
|
@ -6,13 +6,13 @@
|
|||
showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, globals) {
|
||||
'use strict';
|
||||
|
||||
const regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
|
||||
base64Regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z\d+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
|
||||
const regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*((?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0)))/gm,
|
||||
base64Regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z\d+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*((?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[)))/gm;
|
||||
|
||||
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
|
||||
text += '¨0';
|
||||
|
||||
let replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
|
||||
let replaceFunc = function (wholeMatch, linkId, url, width, height, rest, blankLines, title) {
|
||||
|
||||
// if there aren't two instances of linkId it must not be a reference link so back out
|
||||
linkId = linkId.toLowerCase();
|
||||
|
@ -29,14 +29,45 @@ showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, glo
|
|||
}
|
||||
|
||||
if (blankLines) {
|
||||
// Oops, found blank lines, so it's not a title.
|
||||
// Put back the parenthetical statement we stole.
|
||||
return blankLines + title;
|
||||
|
||||
// oops, found blank lines, so it's not a title, put back the
|
||||
// parenthetical statement we stole
|
||||
//
|
||||
// if a input such as below is provided the rest of the string needs to be
|
||||
// returned, in this case it would match the headers of the table, but
|
||||
// they need to be returned as original, otherwise the rendering will not
|
||||
// work, see issue #929 for details
|
||||
//
|
||||
// https://github.com/showdownjs/showdown/issues/929
|
||||
//
|
||||
// === input
|
||||
// [^1]: https://example.com =200x200
|
||||
//
|
||||
// | Column1 | Column2 |
|
||||
// | --- | --- |
|
||||
// | key | value |
|
||||
// ===
|
||||
//
|
||||
// === whole match
|
||||
// [^1]: https://example.com =200x200
|
||||
//
|
||||
// | Column1 | Column2 |
|
||||
// ===
|
||||
//
|
||||
// === rest
|
||||
//
|
||||
// | Column1 | Column2 |
|
||||
// ===
|
||||
//
|
||||
// in this case it should omit the URL and return the rest of the string
|
||||
// since due to the blank line we know it isn't a title, the new lines are
|
||||
// important as changing these will also result in the subsequent table
|
||||
// breaking
|
||||
return rest;
|
||||
} else {
|
||||
if (title) {
|
||||
globals.gTitles[linkId] = title.replace(/["']/g, '"');
|
||||
}
|
||||
|
||||
if (options.parseImgDimensions && width && height) {
|
||||
globals.gDimensions[linkId] = {
|
||||
width: width,
|
||||
|
@ -44,7 +75,8 @@ showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, glo
|
|||
};
|
||||
}
|
||||
}
|
||||
// Completely remove the definition from the text
|
||||
|
||||
// completely remove the definition from the text
|
||||
return '';
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<p>Footnote <a href="https://example.com">^1</a></p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>C1</th>
|
||||
<th>C2</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>k1</td>
|
||||
<td>v2</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,7 @@
|
|||
Footnote [^1]
|
||||
|
||||
[^1]: https://example.com
|
||||
|
||||
| C1 | C2 |
|
||||
| --- | --- |
|
||||
| k1 | v2 |
|
Loading…
Reference in New Issue
Block a user