-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-image-comparison.js
More file actions
63 lines (46 loc) · 2.18 KB
/
debug-image-comparison.js
File metadata and controls
63 lines (46 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Debug script to compare working vs non-working image scenarios
// Working scenario: Manual markdown in template
const workingTemplate = `
# Safety Plan
## Manual Image (This Works)

## Template Variable (This Doesn't Work)
{{detalles_graficos}}
`
// Non-working scenario: Template with variable
const templateData = {
detalles_graficos: ``
}
// Let's simulate the processing
const marked = require('marked')
console.log('=== DEBUGGING IMAGE PROCESSING COMPARISON ===\n')
// 1. Working scenario
console.log('1. WORKING SCENARIO - Manual markdown:')
console.log('Template content:', workingTemplate)
const workingHtml = marked(workingTemplate)
console.log('HTML output:', workingHtml)
const workingImgTags = workingHtml.match(/<img[^>]*>/gi)
console.log('Found img tags:', workingImgTags)
// 2. Non-working scenario
console.log('\n2. NON-WORKING SCENARIO - Template variable:')
console.log('Template data:', templateData)
const filledTemplate = workingTemplate.replace('{{detalles_graficos}}', templateData.detalles_graficos)
console.log('Filled template:', filledTemplate)
const nonWorkingHtml = marked(filledTemplate)
console.log('HTML output:', nonWorkingHtml)
const nonWorkingImgTags = nonWorkingHtml.match(/<img[^>]*>/gi)
console.log('Found img tags:', nonWorkingImgTags)
// 3. Compare the differences
console.log('\n3. COMPARISON:')
if (workingImgTags && nonWorkingImgTags) {
console.log('Working img tag:', workingImgTags[0])
console.log('Non-working img tag:', nonWorkingImgTags[0])
// Extract src attributes
const workingSrc = workingImgTags[0].match(/src="([^"]+)"/)
const nonWorkingSrc = nonWorkingImgTags[0].match(/src="([^"]+)"/)
console.log('Working src:', workingSrc ? workingSrc[1] : 'No src found')
console.log('Non-working src:', nonWorkingSrc ? nonWorkingSrc[1] : 'No src found')
// Check for differences in attributes
console.log('Working attributes:', workingImgTags[0].match(/\w+="[^"]*"/g))
console.log('Non-working attributes:', nonWorkingImgTags[0].match(/\w+="[^"]*"/g))
}