Earlier quoted context omitted.
There are tools to do exactly that, like a simple bash scripts lit.sh: https://github.com/vijithassar/lit Pandoc is a nice swiss army knife that can do a similar conversion with some custom lua filters. It could even do wackier stuff like convert word or odt files to code if you were really diving into prose-first coding. I've also heard it referred to as 'semi-literate programming' because it skips the reorganizatio…
As long as these are external tools, IDEs and things like github's default file renderer aren't going to understand what's going on.
VS code is getting pretty smart about code notebooks too, it has native support for a few different formats of markdown + code blocks (hydrogen, jupyter, etc) and applies all the right syntax highlighting, analysis, etc. to each block automatically.