#!/usr/bin/env node // Test numeric entity decoding const testString = 'type=”in_container”'; console.log('Original:', testString); // Method 1: Manual replacement let method1 = testString .replace(/”/g, '"') .replace(/“/g, '"') .replace(/‘/g, "'") .replace(/’/g, "'") .replace(/–/g, '-') .replace(/—/g, '—'); console.log('Method 1 (Unicode chars):', method1); // Method 2: Numeric entity decoding let method2 = testString .replace(/”/g, '"') .replace(/“/g, '"') .replace(/‘/g, "'") .replace(/’/g, "'") .replace(/–/g, '-') .replace(/—/g, '—') .replace(/…/g, '…') .replace(/″/g, '"') .replace(/′/g, "'"); console.log('Method 2 (Numeric entities):', method2); // Method 3: Using a function to decode all numeric entities function decodeHTMLEntities(str) { return str.replace(/(\d+);/g, (match, dec) => { return String.fromCharCode(dec); }); } let method3 = decodeHTMLEntities(testString); console.log('Method 3 (All numeric):', method3); // Method 4: Combined approach function comprehensiveEntityDecode(str) { return str // First decode numeric entities .replace(/(\d+);/g, (match, dec) => String.fromCharCode(dec)) // Then handle any remaining Unicode characters .replace(/”/g, '"') .replace(/“/g, '"') .replace(/‘/g, "'") .replace(/’/g, "'") .replace(/–/g, '-') .replace(/—/g, '—') .replace(/…/g, '…') .replace(/″/g, '"') .replace(/′/g, "'"); } let method4 = comprehensiveEntityDecode(testString); console.log('Method 4 (Combined):', method4); // Test with the actual excerpt const actualExcerpt = '
[vc_row type=”in_container” full_screen_row_position=”middle” column_margin=”default”]'; console.log('\n=== Real Test ==='); console.log('Original:', actualExcerpt); console.log('Decoded:', comprehensiveEntityDecode(actualExcerpt));