-4

This question already has an answer here:

Answers to coding questions often use a minor change to the example code. But because it's code, you cant emphasize those differences with markdown syntax.

See example below where I've done some gymnastics to show a diff:


Example Question

Why isn't his working?

<htwl>
<body>
    document
</body>
</html>

Example Answer

Ah, just a typo. You meant:

<htwl>
<html>
    <body>
        document
    </body>
</html>


In the above example answer, I used a quote block instead of code block, and <del> to strikeout the old line, and HTML character entities (including &nbsp; for indentation) to make sure the HTML didn't render as HTML. Painful.

I don't necessarily need to see a full diff, (as in git) where the old line is red and in ~strikeout~ and the new line is green. But it would be nice to give some sort of indication within a code block to emphasize or hi-light a particular change, to focus attention on that line. But of course, you cant use markdown inside of a code block!

That could really be anything: the ability to make a line bold, or a different color, or put a little arrow outside the left margin of that line. Anything to focus attention to certain lines.

marked as duplicate by Nathan Tuggy, rene, Ward, Marshmallow, Glorfindel Aug 12 '17 at 20:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8

Besides that just typo questions should be flagged rather than answered, you can always (almost?) use (language specific) comments to highlight your code changes:

Ah, just a typo. You meant:

<html><!-- <<<<<<<<< <htwl> is mistyped -->
    <body>
        document
    </body>
</html>

Not only that's more natural to read for programmers familiar with a specific programming or markup language, and seen out in the wild1, it's also not worth putting efforts on such a feature IMO.


1) Typical example (C++):

i += 10; // 08/11/2017, GMA fixed typo: i =+ 10;

  • I get what you're saying, but if the original example already has a lot of comments (which is common) then it can be hard to see the new comments. – brentonstrine Aug 11 '17 at 18:35
  • 1
    @brentonstrine "but if the original example already has a lot of comments ..." I'd rip out anything irrelevant from my answer code anyways. If you need a [MCVE] refer to some online compiler or use an external runnable snippet. – user0042 Aug 11 '17 at 18:43
  • 1
    @user0042 "Not only that's more natural ..." That deserves an upvote. – πάντα ῥεῖ Aug 11 '17 at 19:48

Not the answer you're looking for? Browse other questions tagged .