n8n-nodes-notion-advanced 1.2.25-beta → 1.2.27-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.
@@ -482,25 +482,28 @@ class NotionAITool {
|
|
482
482
|
// Skip completely empty lines and placeholder artifacts
|
483
483
|
if (!trimmedLine || /__BLOCK_\d+__/.test(trimmedLine) || /^\d+__$/.test(trimmedLine))
|
484
484
|
continue;
|
485
|
-
// Skip lines that contain XML tag patterns (to prevent double processing)
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
485
|
+
// Skip lines that contain ANY XML/HTML tag patterns (to prevent double processing)
|
486
|
+
// This is a comprehensive check to ensure NO XML content gets processed twice
|
487
|
+
const hasAnyXmlTags = (
|
488
|
+
// Basic XML/HTML tag detection
|
489
|
+
/<[^>]+>/.test(trimmedLine) ||
|
490
|
+
// HTML-encoded tags
|
491
|
+
/<[^&]+>/.test(trimmedLine) ||
|
492
|
+
// Any opening or closing XML/HTML tags
|
493
|
+
/<\/?[a-zA-Z][a-zA-Z0-9]*[^>]*>/.test(trimmedLine) ||
|
491
494
|
// Self-closing tags
|
492
|
-
/<
|
493
|
-
//
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
if (
|
503
|
-
continue; // Skip
|
495
|
+
/<[a-zA-Z][a-zA-Z0-9]*[^>]*\/>/.test(trimmedLine) ||
|
496
|
+
// Common XML/HTML tag names (comprehensive list)
|
497
|
+
/<\/?(?:h[1-6]|p|div|span|ul|ol|li|strong|b|em|i|code|pre|blockquote|callout|todo|image|embed|bookmark|equation|toggle|quote|divider|br|a|u|s|del|mark)\b[^>]*>/i.test(trimmedLine) ||
|
498
|
+
// Specific attribute patterns
|
499
|
+
/(?:type|src|href|alt|language|checked)="[^"]*"/.test(trimmedLine) ||
|
500
|
+
// Any line that looks like it contains XML structure
|
501
|
+
/^\s*<[^>]+>.*<\/[^>]+>\s*$/.test(trimmedLine) ||
|
502
|
+
// Lines that start or end with XML tags
|
503
|
+
/^\s*<[^>]+>/.test(trimmedLine) ||
|
504
|
+
/<\/[^>]+>\s*$/.test(trimmedLine));
|
505
|
+
if (hasAnyXmlTags) {
|
506
|
+
continue; // Skip ALL lines containing XML content to prevent double processing
|
504
507
|
}
|
505
508
|
// Traditional markdown patterns (for backwards compatibility)
|
506
509
|
if (trimmedLine.startsWith('# ')) {
|
@@ -742,17 +745,19 @@ class NotionAITool {
|
|
742
745
|
return charIndex;
|
743
746
|
}
|
744
747
|
}
|
745
|
-
//
|
748
|
+
// Enhanced hierarchical XML tree structure that catches ALL XML content
|
746
749
|
static buildXMLTree(content, tagProcessors) {
|
750
|
+
var _a;
|
747
751
|
const allMatches = [];
|
748
|
-
|
752
|
+
const processedRanges = [];
|
753
|
+
// Step 1: Collect all XML tags with specific processors
|
749
754
|
tagProcessors.forEach(({ regex, blockCreator, listProcessor }) => {
|
750
755
|
var _a;
|
751
756
|
const globalRegex = new RegExp(regex.source, 'gis');
|
752
757
|
let match;
|
753
758
|
while ((match = globalRegex.exec(content)) !== null) {
|
754
759
|
const tagName = ((_a = match[0].match(/<(\w+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'unknown';
|
755
|
-
|
760
|
+
const xmlNode = {
|
756
761
|
id: `${tagName}_${match.index}_${Date.now()}_${Math.random()}`,
|
757
762
|
tagName,
|
758
763
|
start: match.index,
|
@@ -765,12 +770,43 @@ class NotionAITool {
|
|
765
770
|
innerContent: match[0],
|
766
771
|
replacement: undefined,
|
767
772
|
listProcessor
|
768
|
-
}
|
773
|
+
};
|
774
|
+
allMatches.push(xmlNode);
|
775
|
+
processedRanges.push({ start: xmlNode.start, end: xmlNode.end });
|
769
776
|
}
|
770
777
|
});
|
771
|
-
//
|
778
|
+
// Step 2: Catch ANY remaining XML/HTML tags that weren't processed by specific processors
|
779
|
+
// This prevents ANY XML content from falling through to traditional processing
|
780
|
+
const genericXmlRegex = /<[^>]+>[\s\S]*?<\/[^>]+>|<[^>]+\/>/gis;
|
781
|
+
let genericMatch;
|
782
|
+
while ((genericMatch = genericXmlRegex.exec(content)) !== null) {
|
783
|
+
const matchStart = genericMatch.index;
|
784
|
+
const matchEnd = genericMatch.index + genericMatch[0].length;
|
785
|
+
// Check if this match overlaps with any already processed range
|
786
|
+
const hasOverlap = processedRanges.some(range => (matchStart < range.end && matchEnd > range.start));
|
787
|
+
if (!hasOverlap) {
|
788
|
+
const tagName = ((_a = genericMatch[0].match(/<(\w+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'generic';
|
789
|
+
const xmlNode = {
|
790
|
+
id: `${tagName}_${matchStart}_${Date.now()}_${Math.random()}`,
|
791
|
+
tagName,
|
792
|
+
start: matchStart,
|
793
|
+
end: matchEnd,
|
794
|
+
match: genericMatch[0],
|
795
|
+
processor: () => null, // Generic processor that just removes the content
|
796
|
+
groups: [],
|
797
|
+
children: [],
|
798
|
+
depth: 0,
|
799
|
+
innerContent: genericMatch[0],
|
800
|
+
replacement: undefined,
|
801
|
+
listProcessor: undefined
|
802
|
+
};
|
803
|
+
allMatches.push(xmlNode);
|
804
|
+
processedRanges.push({ start: matchStart, end: matchEnd });
|
805
|
+
}
|
806
|
+
}
|
807
|
+
// Sort by start position to maintain document order
|
772
808
|
allMatches.sort((a, b) => a.start - b.start);
|
773
|
-
// Build parent-child relationships
|
809
|
+
// Build parent-child relationships while preserving ordering
|
774
810
|
const rootNodes = [];
|
775
811
|
const nodeStack = [];
|
776
812
|
for (const node of allMatches) {
|
@@ -843,18 +879,18 @@ class NotionAITool {
|
|
843
879
|
// Handle special list processors
|
844
880
|
if (node.listProcessor && (node.tagName === 'ul' || node.tagName === 'ol')) {
|
845
881
|
node.listProcessor(innerContent, blocks);
|
846
|
-
return
|
882
|
+
return ''; // Remove completely - no placeholder needed
|
847
883
|
}
|
848
884
|
// Use blockCreator to create the block
|
849
885
|
const block = node.processor(...node.groups);
|
850
886
|
if (block) {
|
851
887
|
blocks.push(block);
|
852
888
|
}
|
853
|
-
return
|
889
|
+
return ''; // Remove completely - no placeholder needed
|
854
890
|
}
|
855
891
|
catch (error) {
|
856
892
|
console.warn(`Error processing XML node ${node.tagName}:`, error);
|
857
|
-
return
|
893
|
+
return ''; // Remove even on error to prevent artifacts
|
858
894
|
}
|
859
895
|
};
|
860
896
|
// Process all root nodes
|
@@ -1167,9 +1203,7 @@ class NotionAITool {
|
|
1167
1203
|
const replacements = NotionAITool.processXMLTreeDepthFirst(xmlTree, blocks, counterRef);
|
1168
1204
|
// Step 3: Apply hierarchical replacements to content
|
1169
1205
|
processedContent = NotionAITool.applyHierarchicalReplacements(processedContent, xmlTree, replacements);
|
1170
|
-
// Step 4:
|
1171
|
-
processedContent = NotionAITool.cleanupAllPlaceholders(processedContent);
|
1172
|
-
// Step 5: Clean up any remaining HTML tags
|
1206
|
+
// Step 4: Clean up any remaining HTML tags
|
1173
1207
|
processedContent = NotionAITool.cleanupRemainingHtml(processedContent);
|
1174
1208
|
if (DEBUG_ORDERING) {
|
1175
1209
|
console.log(`Processed ${xmlTree.length} root XML nodes hierarchically, created ${blocks.length} blocks`);
|
@@ -1193,11 +1227,11 @@ class NotionAITool {
|
|
1193
1227
|
if (block) {
|
1194
1228
|
blocks.push(block);
|
1195
1229
|
}
|
1196
|
-
return
|
1230
|
+
return ''; // Remove completely - no placeholder needed
|
1197
1231
|
}
|
1198
1232
|
catch (error) {
|
1199
1233
|
console.warn('Error in fallback processor:', error);
|
1200
|
-
return
|
1234
|
+
return ''; // Remove even on error
|
1201
1235
|
}
|
1202
1236
|
},
|
1203
1237
|
groups: match.slice(1)
|
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.27-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": [
|