Created
May 7, 2021 18:13
-
-
Save ctrekker/4ada5e942255900de2c041da0e19ebc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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