@@ -39,12 +39,10 @@ export type NotebookTransform = (
39
39
) => Notebook | Promise < Notebook > ;
40
40
41
41
export interface ObservableOptions {
42
- /** The global window, for the default parser and serializer implementations. */
43
- window ?: Pick < typeof globalThis , "DOMParser" | "XMLSerializer" > ;
42
+ /** The global window, for the default parser implementations. */
43
+ window ?: Pick < typeof globalThis , "DOMParser" > ;
44
44
/** The parser implementation; defaults to `new window.DOMParser()`. */
45
45
parser ?: DOMParser ;
46
- /** The serializer implementation; defaults to `new window.XMLSerializer()`. */
47
- serializer ?: XMLSerializer ;
48
46
/** The path to the page template; defaults to the default template. */
49
47
template ?: string ;
50
48
/** An optional function which transforms the template HTML for the current page. */
@@ -56,7 +54,6 @@ export interface ObservableOptions {
56
54
export function observable ( {
57
55
window = new JSDOM ( ) . window ,
58
56
parser = new window . DOMParser ( ) ,
59
- serializer = new window . XMLSerializer ( ) ,
60
57
template = fileURLToPath ( import . meta. resolve ( "../templates/default.html" ) ) ,
61
58
transformTemplate = ( template ) => template ,
62
59
transformNotebook = ( notebook ) => notebook
@@ -125,10 +122,11 @@ export function observable({
125
122
// Don’t error if assets are missing (matching Vite’s behavior).
126
123
filterMissingAssets ( assets , dirname ( context . filename ) ) ;
127
124
128
- const output = serializer . serializeToString ( document ) ;
125
+ const output = document . documentElement . outerHTML ;
129
126
const i = output . indexOf ( "</body>" ) ;
130
127
if ( ! ( i >= 0 ) ) throw new Error ( "body not found" ) ;
131
128
return (
129
+ `<!doctype html>` +
132
130
output . slice ( 0 , i ) +
133
131
`<style type="text/css">
134
132
@import url("observable:styles/theme-${ notebook . theme } .css");
0 commit comments