32

I have seen so many people confuse ``` with ''', resulting in a post that needs to be edited. Can the linter add a warning that ''' does not highlight code, or can it be added in the sidebar?

16
  • 13
    It occurs to me that using the tilde (~~~) instead of the backtic in the sidebar might be advantageous here. Although... That might be harder to read; the tildes kinda run together a bit. BTW: about 36 posts made this mistake in the past 2 days.
    – Shog9
    Apr 17, 2019 at 1:43
  • 29
    Side note: Python multiline (triple-quote) string literals use ''' or """ as delimiters, and multiline strings are commonly placed at the top of a module, class or function as documentation. Don’t confuse that use for a misspelling of code fencing.
    – Martijn Pieters Mod
    Apr 17, 2019 at 9:51
  • @Shog9: how many of those cases were Python questions?
    – Martijn Pieters Mod
    Apr 17, 2019 at 9:55
  • @MartijnPieters that might make it hard for a linter but to a human it's often evident when there is a docstring or code fencing. Part of the distinction is that code doesn't appear in docstrings
    – Alec
    Apr 17, 2019 at 16:59
  • 4
    @alec_a: code can easily appear in docstrings..
    – Martijn Pieters Mod
    Apr 17, 2019 at 17:00
  • My mistake. It’s still easily apparent to humans though.
    – Alec
    Apr 17, 2019 at 17:34
  • 3
    @MartijnPieters Presumably, any properly used python multiline string literals would be located inside a code block already, right? So we could only gave a warning if the ''' was outside a code block.
    – divibisan
    Apr 17, 2019 at 18:09
  • 1
    @divibisan: no, not if the OP didn't format their code properly. My point is that in such cases you can't automatically distinguish between mistaking ''' for a code-fence and the legitimate Python syntax.
    – Martijn Pieters Mod
    Apr 17, 2019 at 18:15
  • 3
    @MartijnPieters True, but in that case there is still a problem with the code fencing, so a gentle warning about improperly formatted code block would still be appropriate
    – divibisan
    Apr 17, 2019 at 18:17
  • Seeing SO already uses tags for language highlighting already. exceptions like Python could be handled differently by either not showing the warning. Or adding a bit of text saying it may not be the case for python users
    – Remy
    Apr 18, 2019 at 6:55
  • 3
    Unpopular opinion: If the question is older than a few minutes, downvote and move on. This mistake should be very noticeable to the OP after posting and easy enough to fix.
    – idmean
    Apr 18, 2019 at 19:01
  • I wonder why OP didn't correct the error in the review step. (Probablybecause the source is put at the first and the OP thought they should review that!?)
    – user202729
    Apr 19, 2019 at 13:48
  • 1
    > python has left the chat
    – cs95
    Apr 19, 2019 at 20:52
  • @user202729 does anyone actually use guided mode?
    – Alec
    Apr 20, 2019 at 7:15
  • Currently they're the default for users with less than 111 rep.
    – user202729
    Apr 20, 2019 at 7:21

0

You must log in to answer this question.

Browse other questions tagged .