@@ -67,9 +67,18 @@ def parse(self) -> None:
67
67
code_lines .append (lines [i ])
68
68
i += 1
69
69
70
- # Add code cell (with options as comments at the top)
71
- full_code = cell_options + code_lines
72
- self ._add_code_cell (full_code , lang )
70
+ # Check if this is the Pkg.instantiate() cell that we want to skip
71
+ code_content = '\n ' .join (code_lines ).strip ()
72
+ is_pkg_instantiate = (
73
+ 'using Pkg' in code_content and
74
+ 'Pkg.instantiate()' in code_content and
75
+ len (code_content .split ('\n ' )) <= 3 # Only skip if it's just these lines
76
+ )
77
+
78
+ # Add code cell (with options as comments at the top) unless it's the Pkg.instantiate cell
79
+ if not is_pkg_instantiate :
80
+ full_code = cell_options + code_lines
81
+ self ._add_code_cell (full_code , lang )
73
82
74
83
i += 1 # Skip closing ```
75
84
else :
@@ -129,8 +138,20 @@ def _add_code_cell(self, lines: List[str], lang: str) -> None:
129
138
130
139
def to_notebook (self ) -> Dict [str , Any ]:
131
140
"""Convert parsed cells to Jupyter notebook format."""
141
+ # Add package activation cell at the top for Julia notebooks
142
+ cells = self .cells
143
+ if self .kernel_name .startswith ("julia" ):
144
+ pkg_cell = {
145
+ "cell_type" : "code" ,
146
+ "execution_count" : None ,
147
+ "metadata" : {},
148
+ "outputs" : [],
149
+ "source" : "using Pkg; Pkg.activate(; temp=true)"
150
+ }
151
+ cells = [pkg_cell ] + self .cells
152
+
132
153
notebook = {
133
- "cells" : self . cells ,
154
+ "cells" : cells ,
134
155
"metadata" : {
135
156
"kernelspec" : {
136
157
"display_name" : "Julia 1.11" ,
0 commit comments