Skip to content

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Jun 24, 2025

Work in progress

This PR allows you to configure how notebook files are stored. Files can be stored:

  1. As they are now – in executable order, with a section Cell order at the bottom.
  2. In a new format – in visual order, without the Cell order section

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 .jl Pluto 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

@fonsp fonsp added backend Concerning the julia server and runtime ai editor LLM-related features labels Jun 24, 2025
@fonsp
Copy link
Owner Author

fonsp commented Jun 24, 2025

πŸ™ˆ But now it's not storing the code visible/hidden status... Need to rethink this

@PatrickHaecker
Copy link

πŸ™ˆ 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.

@fonsp
Copy link
Owner Author

fonsp commented Jul 1, 2025

Yes! Actually I want to store it as cell metadata (just like "disabled")

@fonsp
Copy link
Owner Author

fonsp commented Jul 1, 2025

Updated parser factored out into #3285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai editor LLM-related features backend Concerning the julia server and runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Cell order section in .jl file

2 participants