Are you able to tell in a CodeBlockProcessor if the code has changed?

I’m trying to build a LilyPond plugin. Since LilyPond compiles and is generated server side, each time my registerMarkdownCodeBlockProcessor is called, I execute lilypond for the codeblock and use an image tag to display the generated output.

However, given this takes a few seconds, when you swap between notes that use this codeblock, there’s a few second delay before it shows.

But, I don’t have to have this delay if I can tell that the lilypond codeblock contents haven’t changed, and just show the last generated image output instead (i.e. if I swap between editing and view modes, or toggle between notes).

Is there a flag that gets passed in that indicates the user actually edited the codeblock contents instead of it just being render for some other reason?

I’ve got a solution here for myself. I simply write out the original source file to a subdirectory (which I need to do anyways to compile with lilypond), and I have my old copy that I can compare to my new copy.

I did not find a way to do this without writing my own copy of the original file out to disk.