๐งพ Options to store notebook in visual order or executable order
Work in progress
This PR allows you to configure how notebook files are stored. Files can be stored:
- As they are now โ in executable order, with a section
Cell orderat the bottom. - In a new format โ in visual order, without the
Cell ordersection
This new format is:
- more useful with git (smaller diffs)
- more useful with AI codegen (easier for the AI to write new cells in the correct place), together with
auto_reload_from_file=true - more useful when editing Pluto notebook files outside of Pluto by hand (although this is not a use case I want to spend to much time on)
Backward compatibility
The new format can already be opened in old Pluto versions, but unfortunately the cells will appear in random order... (because they are stored in an unordered Dict).
Configuration
This adds two new configurations:
store_in_executable_order_new::Bool = true For newly created files, should the notebook file store cells in executable order, so that the notebook file can run as a standalone Julia file? If false, the visual order will be used as the file order, and the Cell order section is ommited.
store_in_executable_order_existing::Union{Nothing,Bool} = nothing After opening an existing notebook, should the notebook file store cells in executable order, so that the notebook file can run as a standalone Julia file? If false, the visual order will be used as the file order, and the Cell order section is ommited. If nothing, the notebook will be saved in the format it was opened in.
Use
The important ideas with this change are:
- You don't need to know about or understand this system to open, use and share Pluto files. If you never look at the literal contents of the
.jlPluto files, you will not see a difference. - By default, existing notebook files should not change file format.
Fix #3179
Try this Pull Request!
Open Julia and type:
julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="no-executable-order")
julia> using Pluto
๐ But now it's not storing the code visible/hidden status... Need to rethink this
๐ But now it's not storing the code visible/hidden status... Need to rethink this
I think the code visible/hidden status needs to be shifted to the cell itself with the new format, i.e. in the # โโโก of the cell itself instead of in the # โ โ at the bottom. I am not sure whether that kill compatibility with opening it from older Pluto versions, though.
Yes! Actually I want to store it as cell metadata (just like "disabled")
Updated parser factored out into #3285