5
\$\begingroup\$

I hit an odd, though not critical bug in the display of assembly language code on the question Disassembler for intel 8080. There's a block of assembly code where the format is:

opcode operand1 operand2   comment

for each line. The poster originally formatted it using a block quote, but noted that it didn't look right. I changed it to be formatted as code, but saw something odd.

When I first did it, I hadn't lined up the comments. So I went back and lined them all up. While editing, the live preview showed that the first 3 lines had one less space before the comment than was actually there. This was odd, but I thought I'd just add a space to those lines. In the live preview they now lined up. But when I pressed the button to save the edits, suddenly they had 1 extra space in the actual display of the assembly code and they no longer aligned.

So I edited it again and removed the extra space. Sure enough the code in the editor looked fine, but the preview showed 1 too few spaces on those lines. But when I saved it, they came back and everything aligned.

\$\endgroup\$
7
\$\begingroup\$

They are caused by tabs, and yes, tabs are "evil" on Stack Exchange. They break code formatting.

Here is shown on the real post, no problem!

real post: correctly aligned

This is shown in the editor, still looks good!

editor: correctly aligned

And this is shown in the preview... hmm?

preview: comments on line 3-5 are missing a whitespace

Finally, this is shown on the revision's source... eh?

revision source: too many tabs on line 1&7

The fix is easy but cumbersome: don't use tabs, align (manually) with spaces instead.

\$\endgroup\$
  • \$\begingroup\$ Ah, OK. That makes some sense. I couldn't figure out what was wrong and basically just modified what was already there. Seems odd that in pre-formatted text with monospaced fonts that tabs would be an issue, but I guess that's where we are. Thanks for the explanation. \$\endgroup\$ – user1118321 Aug 4 '18 at 17:42
  • 2
    \$\begingroup\$ "align (manually) with spaces instead" please don't do that by hand but use an editor converting tabs to spaces instead :-) \$\endgroup\$ – Mast Aug 5 '18 at 6:57

You must log in to answer this question.

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