(head_extra: str, scripts: str)
| 305 | draw(); |
| 306 | })(); |
| 307 | """ |
| 308 | |
| 309 | |
| 310 | def _script_safe(obj) -> str: |
| 311 | """JSON for inlining inside a <script> tag (guard against ``</script>``).""" |
| 312 | return json.dumps(obj).replace("</", "<\\/") |
| 313 | |
| 314 | |
| 315 | def _doc(head_extra: str, scripts: str) -> str: |
| 316 | return ( |
| 317 | '<!doctype html><html><head><meta charset="utf-8">' |
| 318 | + head_extra |
| 319 | + "</head><body>\n" |