Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[
{
"id": "1",
"type": "table",
"props": {
"textColor": "default"
},
"content": {
"type": "tableContent",
"columnWidths": [
null
],
"rows": [
{
"cells": [
{
"type": "tableCell",
"content": [
{
"type": "text",
"text": "Company",
"styles": {
"underline": true
}
}
],
"props": {
"colspan": 1,
"rowspan": 1,
"backgroundColor": "default",
"textColor": "default",
"textAlignment": "left"
}
}
]
},
{
"cells": [
{
"type": "tableCell",
"content": [
{
"type": "text",
"text": "Example Company Inc.",
"styles": {
"bold": true
}
},
{
"type": "text",
"text": "\n \nName: [Company Representative]\nTitle: Chief Executive Officer",
"styles": {}
}
],
"props": {
"colspan": 1,
"rowspan": 1,
"backgroundColor": "default",
"textColor": "default",
"textAlignment": "left"
}
}
]
}
]
},
"children": []
},
{
"id": "2",
"type": "table",
"props": {
"textColor": "default"
},
"content": {
"type": "tableContent",
"columnWidths": [
null
],
"rows": [
{
"cells": [
{
"type": "tableCell",
"content": [
{
"type": "text",
"text": "Advisor",
"styles": {
"underline": true
}
}
],
"props": {
"colspan": 1,
"rowspan": 1,
"backgroundColor": "default",
"textColor": "default",
"textAlignment": "left"
}
}
]
},
{
"cells": [
{
"type": "tableCell",
"content": [
{
"type": "text",
"text": "[Advisor Name]",
"styles": {}
}
],
"props": {
"colspan": 1,
"rowspan": 1,
"backgroundColor": "default",
"textColor": "default",
"textAlignment": "left"
}
}
]
}
]
},
"children": []
}
]
35 changes: 35 additions & 0 deletions packages/core/src/api/parsers/html/parseHTML.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,41 @@ describe("Parse HTML", () => {
await parseHTMLAndCompareSnapshots(html, "parse-div-with-inline-content");
});

it("Parses 2 tables", async () => {
const html = `
<table style="border-collapse:collapse;margin-left:255.478pt" cellspacing="0">
<tr style="height:22pt">
<td style="width:203pt">
<p data-text-alignment="left" data-text-indent="0pt"><u>Company</u></p>
</td>
</tr>
<tr style="height:86pt">
<td style="width:203pt">
<p data-text-alignment="left" data-text-indent="0pt"><b>Example Company Inc.</b></p>
<p data-text-alignment="left" data-text-indent="0pt">
<p>Name: [Company Representative]</p>
</p>
<p data-text-alignment="left" data-text-indent="0pt">Title: Chief Executive Officer</p>
</td>
</tr>
</table>

<table style="border-collapse:collapse;margin-left:256.5pt" cellspacing="0">
<tr style="height:58pt">
<td style="width:209pt;border-bottom-style:solid;border-bottom-width:2pt">
<p data-text-alignment="left" data-text-indent="0pt"><u>Advisor</u></p>
</td>
</tr>
<tr style="height:13pt">
<td style="width:209pt;border-top-style:solid;border-top-width:2pt">
<p data-text-alignment="left" data-text-indent="0pt">[Advisor Name]</p>
</td>
</tr>
</table>`;

await parseHTMLAndCompareSnapshots(html, "parse-2-tables");
});

it("Parse Notion HTML", async () => {
// A few notes on Notion output HTML:
// - Does not preserve text/background colors
Expand Down
Loading