forked from Creditra/Creditra-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_jsx.js
More file actions
26 lines (22 loc) · 736 Bytes
/
Copy pathparse_jsx.js
File metadata and controls
26 lines (22 loc) · 736 Bytes
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
const fs = require('fs');
const content = fs.readFileSync('src/pages/Dashboard.tsx', 'utf8');
let depth = 0;
let lines = content.split('\n');
// very primitive tag counting
let tagRegex = /<\/?([a-zA-Z0-9]+)(>|\s+[^>]*>)/g;
for (let i = 490; i < lines.length; i++) {
let line = lines[i];
// skip comments and simple self closing tags for basic check
if (line.trim().startsWith('//')) continue;
let match;
while ((match = tagRegex.exec(line)) !== null) {
let tag = match[0];
if (tag.startsWith('</')) {
depth--;
console.log(`Line ${i+1}: ${tag} (depth ${depth})`);
} else if (!tag.endsWith('/>')) {
depth++;
console.log(`Line ${i+1}: ${tag} (depth ${depth})`);
}
}
}