Skip to content

Commit c254968

Browse files
authored
Improve notebook generation (#670)
* Improve notebook generation * this isn't python
1 parent 4fba6ec commit c254968

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

assets/scripts/notebooks/notebooks.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function fix_callouts(md_content::AbstractString)::String
6060
# Quarto callouts look like, for example, `::: {.callout-note}`
6161
# There isn't a good Jupyter equivalent, so we'll just use blockquotes.
6262
# https://github.com/quarto-dev/quarto-cli/issues/1167
63-
callout_regex = r"^:::\s*\{\.callout-\w+\}.*$"
63+
callout_regex = r"^:::\s*\{\.callout-.+\}.*$"
6464
callout_end_regex = r"^:::\s*$"
6565
new_lines = String[]
6666
in_callout = false
@@ -116,9 +116,15 @@ function parse_cells(qmd_path::String)::Notebook
116116
lang = match.captures[1]
117117
code = strip(match.captures[2])
118118
if lang == "julia"
119-
cell = JuliaCodeCell(code)
120-
push!(cells, cell)
121-
union!(packages, extract_imports(cell))
119+
if occursin(r"#|\s*eval:\s*false", code)
120+
# This is a code cell that is not meant to be executed.
121+
push!(cells, MarkdownCell("```julia\n$code\n```"))
122+
continue
123+
else
124+
cell = JuliaCodeCell(code)
125+
push!(cells, cell)
126+
union!(packages, extract_imports(cell))
127+
end
122128
else
123129
# There are some code cells that are not Julia for example
124130
# dot and mermaid. You can see what cells there are with

0 commit comments

Comments
 (0)