| 395 | } |
| 396 | |
| 397 | getBackgroundColor(shikiHtml: string): string { |
| 398 | const dom = new JSDOM(shikiHtml); |
| 399 | const document = dom.window.document; |
| 400 | |
| 401 | const preElement = document.querySelector("pre"); |
| 402 | let backgroundColor = "#333333"; // Default white background |
| 403 | if (preElement) { |
| 404 | const style = preElement.getAttribute("style") || ""; |
| 405 | const bgColorMatch = style.match(/background-color:\s*(#[0-9a-fA-F]{6})/); |
| 406 | if (bgColorMatch) { |
| 407 | backgroundColor = bgColorMatch[1]; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | return backgroundColor; |
| 412 | } |
| 413 | |
| 414 | async getDataUri( |
| 415 | code: string, |