Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
### A Pluto.jl notebook ###
# v0.14.5
using Markdown
using InteractiveUtils
# ╔═╡ 0cbce490-af5c-11eb-224c-b761bb1f8571
using Pluto, PlutoUI, UUIDs
# ╔═╡ a5f7d50a-6231-4f42-a756-697cdb0b7c4c
function plutostate_to_julia(statefile::AbstractString, juliafile::AbstractString)
contents = open(f->read(f), statefile_path)
state = Pluto.unpack(contents)
plutostate_to_julia(state, juliafile)
end
# ╔═╡ 7388a575-d078-4076-9369-54a5deaae1d9
function plutostate_to_julia(state::Dict{Any, Any}, juliafile::AbstractString)
cell_order = UUID.(state["cell_order"])
cells_dict = Dict([UUID(k) => Pluto.Cell(cell_id=UUID(k), code=v["code"], code_folded=v["code_folded"]) for (k, v) state["cell_inputs"]])
cells = [cells_dict[id] for id cell_order]
nb = Pluto.Notebook(cells, "", uuid4())
open(juliafile, "w") do io
Pluto.save_notebook(io, nb)
end
end
# ╔═╡ Cell order:
# ╠═0cbce490-af5c-11eb-224c-b761bb1f8571
# ╠═a5f7d50a-6231-4f42-a756-697cdb0b7c4c
# ╠═7388a575-d078-4076-9369-54a5deaae1d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment