n8n-nodes-notion-advanced 1.2.32-beta → 1.2.33-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1487,21 +1487,27 @@ class NotionAITool {
|
|
1487
1487
|
processed = processed.replace(/<\/?li\s*[^>]*>/gi, '');
|
1488
1488
|
// Remove any other common list-related fragments
|
1489
1489
|
processed = processed.replace(/<\/?[uo]l\s*[^>]*>/gi, '');
|
1490
|
-
//
|
1491
|
-
|
1490
|
+
// Convert inline HTML formatting to markdown BEFORE removing tags
|
1491
|
+
processed = NotionAITool.convertInlineHtmlToMarkdown(processed);
|
1492
|
+
// Final cleanup of any remaining unhandled tags
|
1492
1493
|
const result = processed
|
1493
|
-
.replace(/<[^>]*>/g, ' ') // Remove any remaining HTML tags
|
1494
1494
|
.replace(/\s+/g, ' ') // Clean up whitespace
|
1495
1495
|
.trim();
|
1496
1496
|
return result;
|
1497
1497
|
}
|
1498
1498
|
catch (error) {
|
1499
1499
|
console.warn('Error processing nested HTML in list item:', error);
|
1500
|
-
// Fallback:
|
1501
|
-
|
1502
|
-
.
|
1503
|
-
.replace(/\s+/g, ' ')
|
1504
|
-
|
1500
|
+
// Fallback: convert inline HTML then remove any remaining tags
|
1501
|
+
try {
|
1502
|
+
const fallback = NotionAITool.convertInlineHtmlToMarkdown(processed);
|
1503
|
+
return fallback.replace(/\s+/g, ' ').trim();
|
1504
|
+
}
|
1505
|
+
catch (fallbackError) {
|
1506
|
+
return processed
|
1507
|
+
.replace(/<[^>]*>/g, ' ')
|
1508
|
+
.replace(/\s+/g, ' ')
|
1509
|
+
.trim();
|
1510
|
+
}
|
1505
1511
|
}
|
1506
1512
|
}
|
1507
1513
|
// Helper function to convert inline HTML to markdown
|
@@ -1824,13 +1830,30 @@ class NotionAITool {
|
|
1824
1830
|
continue;
|
1825
1831
|
}
|
1826
1832
|
const item = { text: '', children: [] };
|
1827
|
-
//
|
1833
|
+
// STEP 1: Remove child block XML from content to get clean parent text
|
1834
|
+
let parentTextContent = fullItemContent;
|
1835
|
+
// List of XML tags that create child blocks (these should be removed from parent text)
|
1836
|
+
const childBlockTags = [
|
1837
|
+
'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
1838
|
+
'blockquote', 'quote', 'callout', 'code', 'pre',
|
1839
|
+
'todo', 'toggle', 'image', 'embed', 'bookmark',
|
1840
|
+
'equation', 'divider'
|
1841
|
+
];
|
1842
|
+
// Remove child block XML from parent text
|
1843
|
+
childBlockTags.forEach(tag => {
|
1844
|
+
// Remove both self-closing and paired tags
|
1845
|
+
const selfClosingRegex = new RegExp(`<${tag}[^>]*\\/>`, 'gis');
|
1846
|
+
const pairedRegex = new RegExp(`<${tag}[^>]*>.*?<\\/${tag}>`, 'gis');
|
1847
|
+
parentTextContent = parentTextContent.replace(pairedRegex, '');
|
1848
|
+
parentTextContent = parentTextContent.replace(selfClosingRegex, '');
|
1849
|
+
});
|
1850
|
+
// STEP 2: Process the content to separate remaining text from nested lists
|
1828
1851
|
let contentPos = 0;
|
1829
1852
|
let textParts = [];
|
1830
|
-
while (contentPos <
|
1853
|
+
while (contentPos < parentTextContent.length) {
|
1831
1854
|
// Look for the next nested list (ul or ol)
|
1832
|
-
const nextUlStart =
|
1833
|
-
const nextOlStart =
|
1855
|
+
const nextUlStart = parentTextContent.indexOf('<ul', contentPos);
|
1856
|
+
const nextOlStart = parentTextContent.indexOf('<ol', contentPos);
|
1834
1857
|
let nextListStart = -1;
|
1835
1858
|
let listType = '';
|
1836
1859
|
if (nextUlStart !== -1 && (nextOlStart === -1 || nextUlStart < nextOlStart)) {
|
@@ -1843,22 +1866,22 @@ class NotionAITool {
|
|
1843
1866
|
}
|
1844
1867
|
if (nextListStart === -1) {
|
1845
1868
|
// No more nested lists - add remaining text
|
1846
|
-
const remainingText =
|
1869
|
+
const remainingText = parentTextContent.substring(contentPos);
|
1847
1870
|
if (remainingText.trim()) {
|
1848
1871
|
textParts.push(remainingText);
|
1849
1872
|
}
|
1850
1873
|
break;
|
1851
1874
|
}
|
1852
1875
|
// Add text before the nested list
|
1853
|
-
const textBefore =
|
1876
|
+
const textBefore = parentTextContent.substring(contentPos, nextListStart);
|
1854
1877
|
if (textBefore.trim()) {
|
1855
1878
|
textParts.push(textBefore);
|
1856
1879
|
}
|
1857
1880
|
// Find the end of this nested list
|
1858
|
-
const listOpenEnd =
|
1881
|
+
const listOpenEnd = parentTextContent.indexOf('>', nextListStart);
|
1859
1882
|
if (listOpenEnd === -1) {
|
1860
1883
|
// Malformed list tag
|
1861
|
-
textParts.push(
|
1884
|
+
textParts.push(parentTextContent.substring(contentPos));
|
1862
1885
|
break;
|
1863
1886
|
}
|
1864
1887
|
// Track depth to find the matching closing tag
|
@@ -1867,9 +1890,9 @@ class NotionAITool {
|
|
1867
1890
|
let listEnd = -1;
|
1868
1891
|
const openTag = `<${listType}`;
|
1869
1892
|
const closeTag = `</${listType}>`;
|
1870
|
-
while (listSearchPos <
|
1871
|
-
const nextListOpen =
|
1872
|
-
const nextListClose =
|
1893
|
+
while (listSearchPos < parentTextContent.length && listDepth > 0) {
|
1894
|
+
const nextListOpen = parentTextContent.indexOf(openTag, listSearchPos);
|
1895
|
+
const nextListClose = parentTextContent.indexOf(closeTag, listSearchPos);
|
1873
1896
|
if (nextListClose === -1)
|
1874
1897
|
break;
|
1875
1898
|
if (nextListOpen !== -1 && nextListOpen < nextListClose) {
|
@@ -1886,7 +1909,8 @@ class NotionAITool {
|
|
1886
1909
|
}
|
1887
1910
|
}
|
1888
1911
|
if (listEnd !== -1) {
|
1889
|
-
// Extract the content between <ul>/<ol> and </ul>/<ol>
|
1912
|
+
// Extract the content between <ul>/<ol> and </ul>/<ol> from ORIGINAL content
|
1913
|
+
// (not parentTextContent which has child blocks removed)
|
1890
1914
|
const listContent = fullItemContent.substring(listOpenEnd + 1, listEnd - closeTag.length);
|
1891
1915
|
item.children.push({
|
1892
1916
|
type: listType,
|
@@ -1896,7 +1920,7 @@ class NotionAITool {
|
|
1896
1920
|
}
|
1897
1921
|
else {
|
1898
1922
|
// Malformed nested list - treat remaining as text
|
1899
|
-
textParts.push(
|
1923
|
+
textParts.push(parentTextContent.substring(contentPos));
|
1900
1924
|
break;
|
1901
1925
|
}
|
1902
1926
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "n8n-nodes-notion-advanced",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.33-beta",
|
4
4
|
"description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
|
5
5
|
"scripts": {},
|
6
6
|
"files": [
|