23

When discussing unformatted code on meta, I noticed that there is a bug in the warning that says that code isn't formatted. For example, if I enter this, the warning works fine:

warning

However, the following didn't generate any warning, and as you can see in the preview, the code is still badly formatted:

no warning

This issue caused an answer to be badly formatted. You can read about that here.

I think that this should get fixed so that the warning appears every time the code would be badly formatted. Otherwise new users have no way of knowing that their code will be badly formatted when they don't skip a line.

3
  • 8
    Agree completely that this is a bug. The SE Broken Code Detector™ must be made to realize that without adding a new line between the code block and the paragraph, the code is wrongly formatted.
    – Bhargav Rao Mod
    Commented Jan 17, 2017 at 18:27
  • 13
    "have no way of knowing"... except for the blank preview, of course. Still a bug, but I don't think we need to hyperbole. Commented Jan 17, 2017 at 18:41
  • 1
    @MikeMcCaughan That's true. Although they might not understand that it's a preview. In the screenshots I posted it's obvious that it's a preview, but that's not always the case. Commented Jan 17, 2017 at 19:40

1 Answer 1

6

Thanks for your report. The SE Broken Code Detector™ was running through the raw text block without "remembering" the previous lines, and therefore incapable of detecting flaws like the one reported. This issue has now been fixed and should be up with our next prod build (aka, whatever comes after rev 2017.1.17.24712).

4
  • Just curious, 24712 is the total number of builds?
    – Veve
    Commented Jan 18, 2017 at 19:17
  • 1
    @Veve yes. However, build counts are based on our dev builds - which is why we saw a jump from 24712 to 24718 in prod today. It also changes depending on configs, and whether or not we reset them (not sure we ever did, but it would be possible)
    – rla4 StaffMod
    Commented Jan 18, 2017 at 21:05
  • @rla4, What algo does SE use to detect unformatted code blocks?
    – Bhargav Rao Mod
    Commented Jan 23, 2017 at 19:26
  • 1
    @BhargavRao nothing that fancy. We run through lines that look like code (some regex + keyword checking) and verify how many of them start with 4 consecutive spaces.
    – rla4 StaffMod
    Commented Jan 23, 2017 at 19:52

You must log in to answer this question.

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