| 38 | } |
| 39 | |
| 40 | function describeStudioElement(tag: { raw: string; name: string }): string { |
| 41 | const parts = [`<${tag.name}`]; |
| 42 | const className = readAttr(tag.raw, "class"); |
| 43 | const compositionId = readAttr(tag.raw, "data-composition-id"); |
| 44 | const dataStart = readAttr(tag.raw, "data-start"); |
| 45 | const dataTrack = readAttr(tag.raw, "data-track-index") ?? readAttr(tag.raw, "data-track"); |
| 46 | |
| 47 | if (className) { |
| 48 | const primaryClass = className |
| 49 | .split(/\s+/) |
| 50 | .map((value) => value.trim()) |
| 51 | .find((value) => value && value !== "clip"); |
| 52 | if (primaryClass) parts.push(` class="${primaryClass}"`); |
| 53 | } |
| 54 | if (compositionId) parts.push(` data-composition-id="${compositionId}"`); |
| 55 | if (dataStart) parts.push(` data-start="${dataStart}"`); |
| 56 | if (dataTrack) parts.push(` data-track-index="${dataTrack}"`); |
| 57 | parts.push(">"); |
| 58 | return parts.join(""); |
| 59 | } |
| 60 | |
| 61 | const HEAD_BLOCKS_TO_IGNORE_PATTERN = |
| 62 | /<(?:style|script|template|title|noscript)\b[^>]*>[\s\S]*?<\/(?:style|script|template|title|noscript)(?:\s[^>]*)?>/gi; |