-12

I've seen many posts where code formatting is used to highlight keywords (example), which is not really allowed. A lot of these edits are made by low reputation users and get approved by high reputation users, either because they are robo-reviewers or because they don't know it's not allowed. I just flagged a user who had made a lot of those edits for moderator attention, but that's just one user and even if a moderator gets that specific user to stop, others will still continue.

Many keywords that are usually wrongly formatted as code are names of programming languages, such as "C++", "Python", "Javascript", etc, or libraries, such as "Qt" or "OpenGL". My suggestion is to blacklist names of programming languages or libraries wrapped in backticks, so that a post or an edit can't be submitted if it contains for example `C++`, `Python` or `Qt`. There could be a list of names of programming languages and libraries which can't be wrapped with backticks. If a user tries to do so anyway, they could get an error message like this one:

Body cannot contain "<code>C++</code>". Code formatting should only be used for actual code (and code-like artifacts such as file names), not to highlight keywords.

Maybe some programming languages and libraries whose names can also easily be code could be whitelisted, for example C since A, B and C are sometimes used as example class names. Also, programming languages in code formatting should only be blocked if there is nothing else between the backticks, so "javascript" should be blacklisted but not "<script type="text/javascript">" (even though it contains the word "javascript" inside code formatting).

Also, I don't think it's necessary to ban wrapping names of programming languages or libraries inside <code> tags (like <code>C++</code>), since the users who wrap them in backticks would probably stop if they knew it weren't allowed (at least that's my guess) and most of them would probably try backticks first and see the error message and notice that it's not allowed. Also, in the rare cases where something that looks like a name of a programming language or library is actually code (for example if you need python as a variable name or if there is a variable named C that should be incremented by 1, the code for that in most programming languages I know would be C++), it would be good to have a workaround, and that workaround could be using <code> instead of backticks. But if it turns out that I'm wrong and users start abusing the <code> tag too, it might be necessary to ban names of programming languages and libraries inside that too.

8
  • 6
    I'm not sure this would not cause head-aches for false positives. Sometimes you need python as a variable name.
    – Martijn Pieters Mod
    Commented Aug 19, 2017 at 14:05
  • @MartijnPieters In that case, they could use <code>python</code>.
    – anon
    Commented Aug 19, 2017 at 14:07
  • 4
    That still feels like throwing out the baby with the bathwater. Is this really this big a problem?
    – Martijn Pieters Mod
    Commented Aug 19, 2017 at 14:40
  • 3
    @Martijn Pieters: It sure hasn't gotten any smaller after half a decade.
    – BoltClock Mod
    Commented Aug 19, 2017 at 14:49
  • Are you proposing that someone sits down and gathers a list of language, tool and library names to feed into a blacklist, and also manually going through it to do a sanity check and remove potentially ambiguous ones? That does not seem like a good use of anyone's time, and it will only include a fraction of the total "bad" usages. How about you just write a userscript to remove backticks from a selection of text instead? Then you can fix the problem wherever you see it with a single click. Commented Aug 19, 2017 at 15:05
  • @Dukeling Making the list isn't so hard. To start with, there is already a list of programming languages on Wikipedia. The hard part would be to actually block everything that's in that list, and they've already done that for more useless purposes than what I'm suggesting.
    – anon
    Commented Aug 19, 2017 at 17:29
  • So what you are saying is that you want to ban variable names that also is the name of some programming language?
    – klutt
    Commented Jan 27, 2018 at 10:18
  • @anon I would never actually think that some variable names are forbidden, and when confronted on it, I would not think about wrapping a variable name in <code> tags. Actually, never used those. Also, I think it will be cause more trouble than the benefits of readability it gives.
    – Pac0
    Commented Sep 6, 2018 at 10:17

1 Answer 1

15

To me, the juice ain't worth the squeeze.

We don't have enough posts that abuse formatting to such a degree that'd it would be worth investing a developer's time on it; instead, we in the community react and correct these kinds of posts in a more reliable way.

Yes, they're annoying, but it's not worth an automated solution. Not yet, anyway.

4
  • If it ever comes time that we need an automated solution, my proposal would be to just eliminate inline code formatting altogether.
    – Cody Gray Mod
    Commented Aug 19, 2017 at 15:36
  • ... And that's how the holy war began @CodyGray
    – Makoto
    Commented Aug 19, 2017 at 15:37
  • 1
    I think this is mainly a problem in edit suggestions. Once they get 2000 rep, they stop doing that. So maybe don't allow inline code formatting while suggesting edits?
    – user2285236
    Commented Aug 19, 2017 at 15:41
  • 2
    @ayhan: There are valid use cases for inline code formatting in questions. I admit that it does get abused, but removing it for the sake of abusers (which isn't that many in my experience) is going to make for worse edits going forward.
    – Makoto
    Commented Aug 19, 2017 at 16:19

You must log in to answer this question.