My two cents to just those two points you raised:
users may mistakenly take in code comments as part of the provided solution
The syntax highlighting prevents that very well, for example:
#!/bin/bash a=~/dir # fill variable a
Unfortunately syntax highlighting doesn’t seem to work here on meta, but on main the comment would appear greyed out if the code block was preceded by
<!-- language: lang-bash -->
.its not easy to point to a specific code section without repeating it in the text
You can use the usual formatting inside code blocks if you use the html markup, e.g.
<pre><code>#!/bin/<i>bash</i> # italics a=<b>~/dir</b> # bold</code></pre>
gives:
#!/bin/bash # italics a=~/dir # bold