Open hpgmiskin opened 8 years ago
I have two thoughts on how I'd approach this.
1) We've got a good example of what you want to do in the form of our LESS and Markdown transformations. The basic idea is that if we see a *.less
or *.md
file being saved to disk, we also generate an associated *.css
or *.html
file. You can see how I did this here: https://github.com/mozilla/brackets/pull/465
2) You could inject the necessary scripts into the preview (and the published version) such that your Python scripts get automatically run when the page loads or something. Assuming that there is some mechanism in Skulpt to locate, parse, and run python code within a web page, you'd just need to have the necessary parser and runtime scripts get auto-injected and started on page load within the preview iframe. To do that you'd want to add a new remote script that would get injected here: https://github.com/mozilla/brackets/blob/master/src/extensions/default/bramble/lib/PostMessageTransport.js#L194-L198. You can look at https://github.com/mozilla/brackets/blob/master/src/extensions/default/bramble/lib/MouseManagerRemote.js as one such example.
No matter how you approach this, you are going to need to make changes within https://github.com/mozilla/brackets vs. this repo--the Bramble editor/preview iframe gets hosted by Thimble, but the code isn't here.
You might also decide that you want to hack this in at a lower level than what I've described above (e.g., you might want to change the server to assume python files are being requested, and serve .js scripts when they are asked for via URLs). If that's the case, forking Bramble and doing that might be the easiest.
Let me know if you have questions about the above. It's doable, but it will require some surgery on our code to make it happen, and not all of it is easy to find. I'm happy to guide you here if you have questions.
I am looking to integrate Skulpt with Brackets to allow Python code to be executed. Skulpt is a Javascript implementation of Python which means it can be executed on the web. The Skulpt library can provide a graphical output and is used by Trinket.