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:
parent
cb21a91fac
commit
771ada0184
15
packages/app-cli/tests/html_to_md/table_with_caption.html
Normal file
15
packages/app-cli/tests/html_to_md/table_with_caption.html
Normal 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>
|
6
packages/app-cli/tests/html_to_md/table_with_caption.md
Normal file
6
packages/app-cli/tests/html_to_md/table_with_caption.md
Normal 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 |
|
19
packages/app-cli/tests/html_to_md/table_with_colgroup.html
Normal file
19
packages/app-cli/tests/html_to_md/table_with_colgroup.html
Normal 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>
|
4
packages/app-cli/tests/html_to_md/table_with_colgroup.md
Normal file
4
packages/app-cli/tests/html_to_md/table_with_colgroup.md
Normal 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 |
|
@ -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 = {
|
rules.tableSection = {
|
||||||
filter: ['thead', 'tbody', 'tfoot'],
|
filter: ['thead', 'tbody', 'tfoot'],
|
||||||
replacement: function (content) {
|
replacement: function (content) {
|
||||||
|
Loading…
Reference in New Issue
Block a user