• mic_check_one_two@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        15
        ·
        edit-2
        18 hours ago

        Because it’s meant to be a block of code, not something that formats using MarkDown rules. The point of code blocks is that you can use special characters and have them rendered as plaintext, instead of actually working as special characters. For instance, here’s the classic Reddit shrug:
        ¯_(ツ)_/¯

        Notice that the left arm is missing? That’s because the backslash and underscores are both special characters. The backslash cancels out the underscore, making the backslash disappear. Now here’s the same shrug formatted as code:

        ¯\_(ツ)_/¯ 
        

        Notice that the left arm is visible, (or at least, it should be), because none of the characters were treated as special characters. If the left arm is invisible on your client, that is actually an error in parsing the MarkDown formatting.

        Tangentially, if I wanted to format that shrug without the missing arms, it would actually take three backslashes, like this:

        ¯\\\_(ツ)_/¯ 
        

        The first backslash cancels out the second, making the second visible. Then the third cancels out the underscore, making the underscores visible, if I only used two, the backslash would be visible, but the underscores would disappear and make the head italicized. But by using three, we get this:
        ¯\_(ツ)_/¯

        Notice how I was able to actually show how I used all three backslashes, using the code block?

      • Arthur Besse@lemmy.ml
        link
        fedilink
        English
        arrow-up
        9
        ·
        edit-2
        21 hours ago

        compare the rendering of the test output (which i also wrapped in backticks to tell the markdown rendering to render it as code) in my other comment on lemmy vs on piefed.

        Essentially, it is not possible to reliably identify the URLs in code (in a language that is not known to either PyFedi or its markdown parser), because they sometimes are adjacent to otherwise-URL-valid characters which actually terminate the URL in whatever syntax is being used inside the code block. So, even though it is sometimes harmless to auto-linkify inside a code block, it is also often wrong and therefore should not be (and generally is not) done.

        But also, code formatting should be available as a way to disable auto-linkification when a post or comment author wants to (as I did in my original comment).