@@ -43,6 +43,7 @@ def __init__(
43
43
self ,
44
44
rawsource = "" ,
45
45
* children ,
46
+ prefix = JUPYTERLITE_DIR ,
46
47
width = "100%" ,
47
48
height = "100%" ,
48
49
content = [],
@@ -51,6 +52,7 @@ def __init__(
51
52
):
52
53
super ().__init__ (
53
54
"" ,
55
+ prefix = prefix ,
54
56
width = width ,
55
57
height = height ,
56
58
content = content ,
@@ -71,7 +73,7 @@ def html(self):
71
73
)
72
74
73
75
return (
74
- f'<iframe src="{ JUPYTERLITE_DIR } /repl/index.html?{ options } "'
76
+ f'<iframe src="{ self [ "prefix" ] } /repl/index.html?{ options } "'
75
77
f'width="{ self ["width" ]} " height="{ self ["height" ]} " style="{ IFRAME_STYLE } "></iframe>'
76
78
)
77
79
@@ -96,8 +98,14 @@ def run(self):
96
98
width = self .options .pop ("width" , "100%" )
97
99
height = self .options .pop ("height" , "100%" )
98
100
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
+
99
106
return [
100
107
RepliteIframe (
108
+ prefix = prefix ,
101
109
width = width ,
102
110
height = height ,
103
111
content = self .content ,
@@ -111,20 +119,23 @@ def __init__(
111
119
self ,
112
120
rawsource = "" ,
113
121
* children ,
122
+ prefix = JUPYTERLITE_DIR ,
114
123
width = "100%" ,
115
124
height = "1000px" ,
116
125
notebook = None ,
117
126
** attributes ,
118
127
):
119
- super ().__init__ ("" , notebook = notebook , width = width , height = height )
128
+ super ().__init__ (
129
+ "" , prefix = prefix , notebook = notebook , width = width , height = height
130
+ )
120
131
121
132
def html (self ):
122
133
notebook = self ["notebook" ]
123
134
124
135
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 } '
126
137
if notebook is not None
127
- else f" { JUPYTERLITE_DIR } /{ self .lite_app } "
138
+ else f' { self [ "prefix" ] } /{ self .lite_app } '
128
139
)
129
140
130
141
return (
@@ -166,13 +177,18 @@ def run(self):
166
177
width = self .options .get ("width" , "100%" )
167
178
height = self .options .get ("height" , "1000px" )
168
179
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
+
169
186
if self .arguments :
170
187
notebook = self .arguments [0 ]
171
188
172
189
# If we didn't get an absolute path,
173
190
# try to find the Notebook relatively to the source
174
191
if not os .path .isabs (notebook ):
175
- source_location = os .path .dirname (self .get_source_info ()[0 ])
176
192
notebook = os .path .join (source_location , notebook )
177
193
178
194
notebook_name = os .path .basename (notebook )
@@ -185,7 +201,11 @@ def run(self):
185
201
else :
186
202
notebook_name = None
187
203
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
+ ]
189
209
190
210
191
211
class JupyterLiteDirective (_LiteDirective ):
0 commit comments