nomagick commited on
Commit
6fa8ce3
·
unverified ·
1 Parent(s): 706de20

fix: poorly transformed detection

Browse files
backend/functions/src/services/snapshot-formatter.ts CHANGED
@@ -578,11 +578,19 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
578
  }
579
 
580
  if (content.includes('<table') && content.includes('</table>')) {
 
 
 
 
581
  const tableElms = node?.querySelectorAll('table') || [];
582
  const deepTableElms = node?.querySelectorAll('table table');
 
 
 
583
 
584
- if ((deepTableElms?.length || 0) / tableElms.length > 0.6) {
585
- return true;
 
586
  }
587
 
588
  const tbodyElms = node?.querySelectorAll('tbody') || [];
 
578
  }
579
 
580
  if (content.includes('<table') && content.includes('</table>')) {
581
+ if (node?.textContent && content.length > node.textContent.length * 0.8) {
582
+ return true;
583
+ }
584
+
585
  const tableElms = node?.querySelectorAll('table') || [];
586
  const deepTableElms = node?.querySelectorAll('table table');
587
+ if (node && tableElms.length) {
588
+ const wrappingTables = _.without(tableElms, ...Array.from(deepTableElms || []));
589
+ const tableTextsLength = _.sum(wrappingTables.map((x) => (x.innerHTML?.length || 0)));
590
 
591
+ if (tableTextsLength / (content.length) > 0.6) {
592
+ return true;
593
+ }
594
  }
595
 
596
  const tbodyElms = node?.querySelectorAll('tbody') || [];