Skip to content

Code block within spoiler gives different result than shown in preview #222

Description

@mbomb007

Describe the bug
A code block within a spoiler block gives a different result than shown when looking at the Markdown preview before posting/saving an answer.

To Reproduce

When using the following markdown in the answer editor:

>! ```python
>! if True:
>!     print "Hello World"
>! ```

It shows this result when viewing the preview during editing (with the multi-line code):

Screenshot showing markdown and result when editing an answer

Screenshot is of this answer (it's currently deleted, because it's not yet working as expected)

Note: The markdown only shows as shown in the screenshot when editing an answer and viewing the live markdown preview/result (WYSIWYG), not when editing a question.

Related question

Expected behavior

I would expect the result to look like the preview after posting/saving. I also think that being able to post a code block within a spoiler is useful on https://codegolf.stackexchange.com

Desktop (please complete the following information):

  • OS: Windows 10, 21H2
  • Browser: Chromium 105

Activity

  1. gparyani commented on Sep 14, 2022

    @gparyani

    This isn't exactly a bug in the editor, but rather the fact that the server-side Markdown renderer doesn't support any type of block Markdown formatting in spoilers. The real fix here is to fix the server-side renderer so it supports block formatting in spoilers. In my view, that's unlikely to happen, as that issue has been reported for many years and never gotten any response from Stack Exchange indicating any intent to fix it, even as many duplicates of that issue have been posted over the years, some of which have been closed by Stack Exchange staff.

    The only issue with the Stacks editor is that it incorrectly displays block Markdown formatting correctly, even though the server-side renderer doesn't support it. I do believe that there shouldn't be any discrepancy between the client-side preview and the server-side rendered post. Until such time as the server-side renderer supports block Markdown formatting, the Stacks editor shouldn't correctly display it since it won't be rendered on the server. Alternatively, it should use HTML formatting inside spoilers (since the server-side renderer does support HTML block formatting).

  2. mbomb007 commented on Sep 15, 2022

    @mbomb007
    Author

    Is it possible that spoilers could be made into a block element, like <spoiler></spoiler>?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions