@@ -43,6 +43,7 @@ def __init__(
4343 self ,
4444 rawsource = "" ,
4545 * children ,
46+ prefix = JUPYTERLITE_DIR ,
4647 width = "100%" ,
4748 height = "100%" ,
4849 content = [],
@@ -51,6 +52,7 @@ def __init__(
5152 ):
5253 super ().__init__ (
5354 "" ,
55+ prefix = prefix ,
5456 width = width ,
5557 height = height ,
5658 content = content ,
@@ -71,7 +73,7 @@ def html(self):
7173 )
7274
7375 return (
74- f'<iframe src="{ JUPYTERLITE_DIR } /repl/index.html?{ options } "'
76+ f'<iframe src="{ self [ "prefix" ] } /repl/index.html?{ options } "'
7577 f'width="{ self ["width" ]} " height="{ self ["height" ]} " style="{ IFRAME_STYLE } "></iframe>'
7678 )
7779
@@ -96,8 +98,14 @@ def run(self):
9698 width = self .options .pop ("width" , "100%" )
9799 height = self .options .pop ("height" , "100%" )
98100
101+ prefix = os .path .relpath (
102+ os .path .join (self .env .app .srcdir , JUPYTERLITE_DIR ),
103+ os .path .dirname (self .get_source_info ()[0 ]),
104+ )
105+
99106 return [
100107 RepliteIframe (
108+ prefix = prefix ,
101109 width = width ,
102110 height = height ,
103111 content = self .content ,
@@ -111,20 +119,23 @@ def __init__(
111119 self ,
112120 rawsource = "" ,
113121 * children ,
122+ prefix = JUPYTERLITE_DIR ,
114123 width = "100%" ,
115124 height = "1000px" ,
116125 notebook = None ,
117126 ** attributes ,
118127 ):
119- super ().__init__ ("" , notebook = notebook , width = width , height = height )
128+ super ().__init__ (
129+ "" , prefix = prefix , notebook = notebook , width = width , height = height
130+ )
120131
121132 def html (self ):
122133 notebook = self ["notebook" ]
123134
124135 src = (
125- f" { JUPYTERLITE_DIR } /{ self .lite_app } /{ self .notebooks_path } ?path={ notebook } "
136+ f' { self [ "prefix" ] } /{ self .lite_app } /{ self .notebooks_path } ?path={ notebook } '
126137 if notebook is not None
127- else f" { JUPYTERLITE_DIR } /{ self .lite_app } "
138+ else f' { self [ "prefix" ] } /{ self .lite_app } '
128139 )
129140
130141 return (
@@ -166,13 +177,18 @@ def run(self):
166177 width = self .options .get ("width" , "100%" )
167178 height = self .options .get ("height" , "1000px" )
168179
180+ source_location = os .path .dirname (self .get_source_info ()[0 ])
181+
182+ prefix = os .path .relpath (
183+ os .path .join (self .env .app .srcdir , JUPYTERLITE_DIR ), source_location
184+ )
185+
169186 if self .arguments :
170187 notebook = self .arguments [0 ]
171188
172189 # If we didn't get an absolute path,
173190 # try to find the Notebook relatively to the source
174191 if not os .path .isabs (notebook ):
175- source_location = os .path .dirname (self .get_source_info ()[0 ])
176192 notebook = os .path .join (source_location , notebook )
177193
178194 notebook_name = os .path .basename (notebook )
@@ -185,7 +201,11 @@ def run(self):
185201 else :
186202 notebook_name = None
187203
188- return [self .iframe_cls (notebook = notebook_name , width = width , height = height )]
204+ return [
205+ self .iframe_cls (
206+ prefix = prefix , notebook = notebook_name , width = width , height = height
207+ )
208+ ]
189209
190210
191211class JupyterLiteDirective (_LiteDirective ):
0 commit comments