30

I tried to post this on the new tables feature thread on Meta Stack Exchange but I don't have enough reputation to post an answer or even a comment on the question. It might only be a Stack Overflow bug so maybe it belongs here anyway.

I tried to post this Markdown table:

| Number of bytes | First code point | Last code point | Byte 1 | Byte 2 | Byte 3 | Byte 4 |
| - | ------- | -------- | -------- | -------- | -------- | -------- |
| 1 | U+0000  | U+007F   | 0xxxxxxx |          |          |          |
| 2 | U+0080  | U+07FF   | 110xxxxx | 10xxxxxx |          |          |
| 3 | U+0800  | U+FFFF   | 1110xxxx | 10xxxxxx | 10xxxxxx |          |
| 4 | U+10000 | U+10FFFF | 11110xxx | 10xxxxxx | 10xxxxxx | 10xxxxxx |

It formats correctly in the preview:

Good preview

But the editor claims it's a bad code block and won't let me post the answer:

Warning

3
  • 1
    Now that the announcement on MSE has been unprotected, I have added an answer there: meta.stackexchange.com/a/359346
    – samanthaj
    Commented Jan 7, 2021 at 18:38
  • 4
    This is an interesting one. You managed to trip our code formatting detection quality check with your table. Brief explanation: We run some heuristics against posts before they're saved to see if there are any lines that look like code but aren't marked as code (fenced or indented code blocks). Something in your post is tripping that check. I'll do some digging to see what exactly this is.
    – Ham Vocke StaffMod
    Commented Jan 8, 2021 at 8:11
  • 3
    There are 3 evil TAB characters in the source for the table. Commented Jan 8, 2021 at 18:18

1 Answer 1

16

Thanks for reporting this. I had some fun poking around and here's what I found out:

Whenever you save a post on stackoverflow.com, we run a bunch of quality checks. One of them is checking whether your post contains unformatted code - and as you can see, you tripped this one off.

Checking for unformatted code is mostly a heuristic. We look for typical keywords and characters that often appear in code and if you exceed a certain threshold within a few consecutive lines, we'll show you the "your post appears to contain code" warning you're seeing.

My initial hunch was that the | characters of your table are triggering this but this isn't it (on second thought this would be surprising because then all tables would trigger this check).

It's not the table syntax in your post that's making our code formatting check go wild. It's the many + characters in short succession in your code points that cause it.

As an example, a post like this (without any tables) would trigger the same check:

This is an example

U+0080 U+0080
U+0800
U+10000

A quick workaround would be to mark your code points as inline code. Inline code is exempt from the code formatting check.

Something like this will work:

| Number of bytes | First code point | Last code point | Byte 1 | Byte 2 | Byte 3 | Byte 4 |
| - | ------- | -------- | -------- | -------- | -------- | -------- |
| 1 | `U+0000`  | `U+007F`   | 0xxxxxxx |          |          |          |
| 2 | `U+0080`  | `U+07FF`   | 110xxxxx | 10xxxxxx |          |          |
| 3 | `U+0800`  | `U+FFFF`   | 1110xxxx | 10xxxxxx | 10xxxxxx |          |
| 4 | `U+10000` | `U+10FFFF` | 11110xxx | 10xxxxxx | 10xxxxxx | 10xxxxxx |
Number of bytes First code point Last code point Byte 1 Byte 2 Byte 3 Byte 4
1 U+0000 U+007F 0xxxxxxx
2 U+0080 U+07FF 110xxxxx 10xxxxxx
3 U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxx
4 U+10000 U+10FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
7
  • 1
    until the heuristic changes tomorrow?
    – samanthaj
    Commented Jan 12, 2021 at 5:46
  • 3
    The last time the heuristic changed was in 2019 when balpha introduced fenced code blocks. Other than that it's been exactly the same behavior since 2011. I don't see a reason to get cynical.
    – Ham Vocke StaffMod
    Commented Jan 12, 2021 at 7:46
  • 1
    Sorry I didn't meant to come across as cynical. Rather I meant to gently suggest it would be nice of it was more robust. My first guess at a solution would be to find the tables in the text, remove them with places holders, then pass the remaining text to the "might be a code block" finder rather than just keep praying that more people don't run into this. Like if you were trying to show formulas in an answer on excel you'd likely see lots of + symbols.
    – samanthaj
    Commented Jan 12, 2021 at 13:14
  • 3
    I see where you're coming from but keep in mind that this specific problem has nothing to to with tables at all. I'd argue that formulas in an excel answer qualify as code and should be marked as such. I'm really not opposed to tweaking the heuristics but from my (limited, I'll admit that) experience, they have proven to work kinda okay and I wouldn't want to fix this issue and introduce a host of new ones. Hope that sounds reasonable. If you find other issues, please let me know and we can revisit!
    – Ham Vocke StaffMod
    Commented Jan 12, 2021 at 18:08
  • I had exactly this problem today apparently because my table includes = signs. It was kind of irritating to read "appears to contain code" in the message when that was not the case; it would have really been nice to have a check mark "yes I saw the message but my post does not contain unformatted code so please save the edit." Commented Mar 1, 2022 at 8:29
  • @HamVocke Could making the discussed error message more transparent for the users be an option? E.g. by listing (the most commonly used) characters that tend to trigger it?
    – Astrid E.
    Commented Mar 22, 2022 at 18:53
  • + really causing the problem in table rows
    – RomanG
    Commented Nov 9, 2022 at 15:00

You must log in to answer this question.

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