Open maueroats opened 2 months ago
Filtering out the images and placing them back into the formatted code sounds pretty tricky to me.
But perhaps you can just format only the selected portion of the code? That would just amount to:
(define-script reformat
#:label "Reformat"
(λ (selection)
(program-format selection)))
If the images are only at the top level, it may be possible to split the formatting by blocks and avoid the locations with images, but I haven't dealt much with non-text-only code, so I don't know from the top of my head how to do that.
You'll also need to pass in the column number of the selection as the #:indent
argument, so that fmt
knows how much indentation to use when adding newlines
Running the simple version of the formatter on code with inline images in DrRacket makes the images disappear, just like copy and pasting would.
It would be nice if there were a way to run the formatter and retain the inline images.
For completeness, here is the reformatter quickscript that I am using (which is obviously the root cause of the error).