70

In the past couple of days I've noticed a number of questions that have their code blocks entered like:

`
```
code
```
`

There's a line with a single backtick, then the normal triple-backtick code fence, the code, then the ending code fence, followed by another single backtick.

I've seen this 3 or 4 times, most recently in How to make sure that by default all points are initially in the 2D array in C? (before I edited it to remove the single backticks), so it doesn't seem like an isolated mistake. Has something changed in the new question editor to cause this mistake?

This seems to have coincided with The Ask Wizard (2022) has graduated so I suspect it's related.

16
  • 14
    Can confirm I've seen these, as well. I was getting suspicious. It might be related to The Ask Wizard (2022) has graduated
    – VLAZ
    Commented Oct 26, 2022 at 21:31
  • 1
    @VLAZ Seems like too much of a coincidence not to be related.
    – Barmar
    Commented Oct 26, 2022 at 21:35
  • 11
    All the data points seem to point towards the wizard. All the samples I've seen are from users who used the wizard. It's either something about it and probably the editor in combination that causes it to be added (which wouldn't surprise me, the new editor is still horrid and has more bugs than several bee hives) Commented Oct 26, 2022 at 21:50
  • 3
    @ZoestandswithUkraine The last time I asked a question about strange code formatting the Stacks Editor was also implicated.
    – Barmar
    Commented Oct 26, 2022 at 21:55
  • 2
    We need to add some logic to the paste behavior in Stacks Editor to try to detect this scenario (fenced code block being pasted into inline code block) and in that case, remove the enclosing inline code block.
    – Yaakov Ellis StaffMod
    Commented Oct 27, 2022 at 5:55
  • 5
    Related Stacks-Editor Issue created #230
    – Yaakov Ellis StaffMod
    Commented Oct 27, 2022 at 6:05
  • 4
    @YaakovEllis I think issue #215 is also related: Issue #215 - bug(md-editor) Pasting in code within a fenced code block, creates 2nd inner code block
    – Andrew T.
    Commented Oct 27, 2022 at 6:19
  • 3
    I was just about to report the same bug, this is still happening.
    – Cerbrus
    Commented Nov 30, 2022 at 13:44
  • 2
    Indeed, can we prioritize this or at least disable the wizard until it is fixed? Literally the only difference I've noticed since the wizard was introduced is that code formatting in posts by new users has turned much worse.
    – Lundin
    Commented Dec 1, 2022 at 15:38
  • I started writing up a bug report too, but some way down the list of possibly related questions (after several completely irrelevant questions) there was this one. Yes, please can this be fixed ASAP. It is a nuisance. Commented Dec 8, 2022 at 17:23
  • @JonathanLeffler it's been six weeks since the bug report. Surely the fix is coming within the next fortnight.
    – VLAZ
    Commented Dec 8, 2022 at 17:25
  • 1
    I thought they'd rescinded the 6-8 weeks rule and replaced it with either 6-8 months or 6-8 years, @VLAZ. 😧 I'm just adding another voice to "please fix it". I'm fed up with having to do the fixup for the staff who haven't gotten around to dealing with this mess. There's no point in complaining to the people who post questions (or answers?) with the fault — they didn't know any better. Commented Dec 8, 2022 at 17:28
  • @JonathanLeffler the joke is that 6-8 is never accurate and always takes longer. But I feel your frustration. I have personally stopped editing those because it takes up too much useless time. I can sit all day and edit the questions coming in and it would accomplish almost nothing. I now edit the extra quotes mostly if there are other issues to fix. I can't really waste my time. Otherwise it's just Sisyphean busywork imposed on us.
    – VLAZ
    Commented Dec 8, 2022 at 17:32
  • 1
    @Phil This question is tagged status-review. So it's still being reviewed, not deployed yet.
    – Barmar
    Commented Dec 27, 2022 at 23:52
  • 1
    @Phil acknowledged. We have a code freeze for non-emergency fixes until next week, and the stacks editor update is already queued up for then.
    – Yaakov Ellis StaffMod
    Commented Dec 28, 2022 at 10:38

2 Answers 2

6

Markdown mode in the Stacks Editor will no longer automatically add code fences for pasted-in code. So this will solve the issue for when folks paste code blocks into inline code sections.

It still does not address usability-confusion that may exist when users select an inline code from the menu instead of a code block. This may not be something that we can practically address (it is something that we will be considering moving forward).


ctrl-K and paste
code into the editor
no added code fence

5
  • 1
    I just noticed something new in this question. Every code line has two backticks around it. Is this something the poster did, or is a new bug in the Stacks Editor?
    – Barmar
    Commented Jan 5, 2023 at 21:54
  • 2
    @Barmar Given they added it with an edit, i'd assume this isn't a stacks editor thing
    – Kevin B
    Commented Jan 5, 2023 at 21:58
  • More recently I've been seeing lots of questions with the opposite problem: single-backticked code inside triple backtick code fences. Is this related?
    – Barmar
    Commented Apr 26, 2023 at 17:16
  • Never mind, found this question
    – Barmar
    Commented Apr 26, 2023 at 17:17
  • I mean... the old editor never had this problem, given the code button in the menu served both purposes by using the context in which it was used.
    – Kevin B
    Commented Apr 26, 2023 at 17:19
46

The problem is, in fact, the new Stacks editor used in the wizard.

Just click the "inline code" button and try to paste some code (even a single line triggers it):

pasting a single line code into inline code adds triple-backtick code fences around the code, within the inline code "block"

Note that the code in the clipboard is only:

return new Promise(function (resolve, reject) {

It does not include the code fences that appear when pasting.

1
  • 2
    I can reproduce using the example given above, bu not all codes trigger this behavior. For example, if the clipboard has int i = 10; instead then pasting that does not trigger the triple-ticks. So, makes me think the paste is invoking some parser that inserts triple-ticks only under certain conditions. Commented Nov 17, 2022 at 18:03

You must log in to answer this question.

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