| 715 | } |
| 716 | |
| 717 | function buildHtmlDocument(meta: HtmlDocumentMeta, css: string, html: string): string { |
| 718 | const lines = [ |
| 719 | "<!doctype html>", |
| 720 | "<html>", |
| 721 | "<head>", |
| 722 | ' <meta charset="utf-8" />', |
| 723 | ' <meta name="viewport" content="width=device-width, initial-scale=1" />', |
| 724 | ` <title>${meta.title}</title>`, |
| 725 | ]; |
| 726 | if (meta.author) { |
| 727 | lines.push(` <meta name="author" content="${meta.author}" />`); |
| 728 | } |
| 729 | if (meta.description) { |
| 730 | lines.push(` <meta name="description" content="${meta.description}" />`); |
| 731 | } |
| 732 | lines.push( |
| 733 | ` <style>${css}</style>`, |
| 734 | "</head>", |
| 735 | "<body>", |
| 736 | ' <div id="output">', |
| 737 | html, |
| 738 | " </div>", |
| 739 | "</body>", |
| 740 | "</html>" |
| 741 | ); |
| 742 | return lines.join("\n"); |
| 743 | } |
| 744 | |
| 745 | async function inlineCss(html: string): Promise<string> { |
| 746 | try { |