1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Clipper: handle tables with captions (#9910)

This commit is contained in:
Max Patiiuk 2024-02-12 06:44:50 -08:00 committed by GitHub
parent cb21a91fac
commit 771ada0184
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,15 @@
<table>
<caption>Caption</caption>
<tbody>
<tr>
<th>Row 1, Column 1</th>
<th>Row 1, Column 2</th>
<th>Row 1, Column 3</th>
</tr>
<tr>
<th>Row 2, Column 1</th>
<td>Row 2, Column 2</td>
<td>Row 2, Column 3</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,6 @@
Caption
| | | |
| --- | --- | --- |
| Row 1, Column 1 | Row 1, Column 2 | Row 1, Column 3 |
| Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 |

View File

@ -0,0 +1,19 @@
<table>
<colgroup>
<col />
<col span="2" class="test" />
<col span="2" class="test2" />
</colgroup>
<tbody>
<tr>
<th>Row 1, Column 1</th>
<th>Row 1, Column 2</th>
<th>Row 1, Column 3</th>
</tr>
<tr>
<th>Row 2, Column 1</th>
<td>Row 2, Column 2</td>
<td>Row 2, Column 3</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,4 @@
| | | |
| --- | --- | --- |
| Row 1, Column 1 | Row 1, Column 2 | Row 1, Column 3 |
| Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 |

View File

@ -98,10 +98,23 @@ rules.table = {
}
}
return '\n\n' + emptyHeader + content + '\n\n'
const captionContent = node.caption ? node.caption.textContent || '' : '';
const caption = captionContent ? `${captionContent}\n\n` : '';
const tableContent = `${emptyHeader}${content}`.trimStart();
return `\n\n${caption}${tableContent}\n\n`;
}
}
rules.tableCaption = {
filter: ['caption'],
replacement: () => '',
};
rules.tableColgroup = {
filter: ['colgroup', 'col'],
replacement: () => '',
};
rules.tableSection = {
filter: ['thead', 'tbody', 'tfoot'],
replacement: function (content) {