I try to use images with my beginning students, but the fact that a "clean" Racket file without images, comment boxes, etc. is pretty much plain text and something that contains those things still has a .rkt suffix, but is a much scarier beast is annoying me.
Here are some pain points that WXME files are causing me:
I can't search the contents of my files. (I was looking for a misplaced file that contained certain text, but because WXME separates each bit of text onto a separate line, it didn't get found.)
I've put all my stuff into a private Github repo so that I can keep track of assignments, easily update them, and keep track of the changes I've made. BUT diffing or even just viewing my files online is not a happy experience.
Once you switch to WXME, the tools my school district gives me to use balk at dealing with the files. My students can't preview things on Google Drive, when I upload things to Google Classroom, they're pretty much a black box, and if students want to include Racket work in a portfolio, they have to do screenshots, since they can't expect other people looking at those portfolios to be able to download the files and view them.
This would be somewhat less annoying if I could figure out what WXME actually is so that I could try to manipulate it somehow. But I've looked at the save-file and load-file methods and darned if I can tell where the numbers at the beginning of each line come from or what the overall structure of the format is.
I know this wouldn't work for a pasteboard or for streaming, but what I'd love is a plain text file format that kept the text as much like it appears in DrRacket as possible and put the images and other snips at the end in a format that could be viewed as plain text (Base64?), maybe with a locator that tells where they belong in the file. Or maybe a multi-file format where the binary bits could be split off into their own locations that wouldn't pollute the program text.
If anybody can give me any hints about where to look for the guts of the code that saves/loads WXME, I'd really appreciate it. I've tried following breadcrumbs and searching for definitions, but because save-file and read-file are methods, the arrows in DrRacket don't point to them and I haven't been successful searching for (define (load-file or (define (save-file.
Sorry for the mini-rant, but it's that time of year when spring break is too far away and winter break is long forgotten.
The wxme-port->text-port function replaces certain text-ish snips with their text representation and replaces images (or other non-textual data) by ..
Here is a script that converts WXME to text and locally incorporates WXME conversion into git diff. Of course, it wouldn't work on cloud drives or GitHub, and the output likely can't be executed.
I think what could be done, beyond wxme-port->text-port, is using wxme-port->port. (The WXME decoders in this module is separated from the one DrRacket is using, and it read non-textual data into its own classes (9 WXME Decoding) rather than the snips from the GUI library.)
[…] It's a small reader extension that lets you embed images in a source program as text, so that your whole program doesn't turn into a WXME mess. See the examples.rkt file for examples, and the README for an explanation. (In particular, compare examples.rkt with examples-as-images.rkt.)
I’d like to know if there is support for the idea of adapting the above to support embedded images (sufficiently to complete Quick: An Introduction to Racket with Pictures by this mechanism ) in DrRacket, emacs , Vim and VSCode (though I believe VSCode has some limitations in this regard)
I’m aware that numerous people have seen the capability of including images in code in DrRacket, only to be forced to abandon the idea when it is apparent that it is incompatible with source control and other editors.
While this is probably too large a task for an individual to take on, this might be achievable for a group if it was broken down into separate tasks.
Without committing to do this - what would the roadmap of required tasks to make this possible?
On the contrary, Todd, you sound like someone with a lot of energy for implementing things! Or maybe you're just looking for a break from grading.
I think I understand what you want, and I definitely think it's possible, but I also think it's going to be a good deal of work, and could be hard to maintain.
Before I begin, I should say that nearly everything I say here is supposition based on a moderate amount of knowledge, and that Robby is the one with the answers here. Also, @shhyou clearly understands snip-world well. Perhaps by saying things that are vaguely true, I can help you get closer to what you want.
I think the most important bit of information is this: I could be wrong, but I think you're looking for something that translates things to and from WXME format, and I think you're not going to find that, for the simple reason that WXME is actually a fairly direct serialization of DrRacket's internal text representation. In other words, I think it's the text files that are the ones that involve a certain amount of "translation" (though in this case that translation is more of just a filter).
What you're proposing, then, is extending that translation (the one mapping the internal representation to text) to one that can handle things for which the translation is not an obvious one-to-one mapping.
After thinking about this for ... more time than I really should have spent on this? ... I think that your proposed goal of a file format that represents the text precisely in a way that provides the affordances you want is probably very hard; I think the easy way to get your goals (1) and (2) and part of (3) is just to automate a process of always saving a stripped-down text-only version of each file, possibly in something like a "textual" subdirectory. That is, for every source file foo.rkt that you have, you also save "textual/foo.rkt" which contains the text-only representation of this. Note that I'm explicitly suggesting discarding the non-textual snips in this representation. If you build this into the "save" operation, you should be able to get most of what you want, without really touching the guts of DrRacket.