| 8 | } |
| 9 | |
| 10 | export function concatHtml({ |
| 11 | required = [], |
| 12 | template, |
| 13 | contents |
| 14 | }: ConcatHTMLOptions): string { |
| 15 | const embedSource = template |
| 16 | ? _template(template) |
| 17 | : ({ source }: { source: ConcatHTMLOptions['contents'] }) => source; |
| 18 | const head = required |
| 19 | .map(({ link, src }) => { |
| 20 | if (link && src) { |
| 21 | throw new Error(` |
| 22 | A required file can not have both a src and a link: src = ${src}, link = ${link} |
| 23 | `); |
| 24 | } |
| 25 | if (src) { |
| 26 | return `<script src='${src}' type='text/javascript'></script>`; |
| 27 | } |
| 28 | if (link) { |
| 29 | return `<link href='${link}' rel='stylesheet' />`; |
| 30 | } |
| 31 | return ''; |
| 32 | }) |
| 33 | .join('\n'); |
| 34 | |
| 35 | return `<head>${head}</head>${embedSource({ source: contents }) || ''}`; |
| 36 | } |
| 37 | |
| 38 | export function createPythonTerminal(pythonRunnerSrc: string): string { |
| 39 | const head = |