Shop OBEX P1 Docs P2 Docs Learn Events
May the code blocks be fixed one of these days? — Parallax Forums

May the code blocks be fixed one of these days?

Wuerfel_21Wuerfel_21 Posts: 5,106
edited 2021-12-11 20:35 in General Discussion

This topic has been dormant for a while, but it's still kinda obnoxious.

For those just tuning in the main issues are:

  • can not manually specify syntax highlighting language, autodetect only, leading to wrong and/or misleading highlighting
  • no Spin highlighting (I wrote a hljs plugin to that extent, but apparently integrating that is a major hassle thanks to the [insert insult of choice here] obsfuscation tech the forum software uses)
  • if the code block starts with a blank line, the content just disappears

IDK about y'all, but functioning code blocks on a programming forum, seems like a good thing to have.

Comments

  • Agreed.
    And btw integration was no hassle.
    I'll ask again if the host issues that prevented us completing the previous forum update initiative have been resolved.

  • Wuerfel_21Wuerfel_21 Posts: 5,106
    edited 2021-12-11 21:48

    @VonSzarvas said:
    And btw integration was no hassle.

    Huh, I though there was some issue with the HLJS being weirdly preprocessed in a way we couldn't figure out, but my memory is hazy and I've been using a userscript to override the syntax highlighting. Does Spin highlighting actually work without and I haven't noticed?

    Nope, still not. Either way, the language autodetection is obnoxious.

    CON
        _clkmode  = xtal1 | pll16x
        _xinfreq  = 5_000_000
        left_pin  = 11
        right_pin = 10
    
    OBJ
        sound : "433_retronitus" 
        kb    : "keyboard"
        pst   : "parallax serial terminal"
    
    PUB Main | k
        sound.start(right_pin,left_pin)
        pst.start(115_200)
        kb.startx(8,9, %0_000_100, %11_11111)
        repeat
          pst.hex(k := kb.getkey,8)
          pst.char(13)
          sound.playSoundEffect(7,@killsfx)
          waitcnt(cnt+clkfreq/88)
          case k
            $C0: ' do nothing
            $D0: sound.playSoundEffect(7,@testsfx2)  
            $D1: sound.playSoundEffect(7,@testsfx3)
            other: sound.playSoundEffect(7,@testsfx)
    
    
  • Nah. We had a list of items in the old update thread that I was working through, but we couldn't continue. For me fixing the code highlighting and search are top of the list of outstanding items.

  • Wuerfel_21Wuerfel_21 Posts: 5,106
    edited 2021-12-11 22:36

    Huh, must be remembering it wrong.

    Anyways, for reference, here's a code block I posted in another thread that overflowed the proverbial barrel and caused me to make this thread:

    file "p2com_bootstrap.asm" => "p2com.asm" do |t|
        puts "Generating bare PASM compiler source for bootstrapping"
        # Just remove all the include directives
        File.write(t.name,File.read(t.source).gsub(/include\s*"\w+\.inc"/,''))
    end
    

    Notice how it's ruby code, but it gets misdetected as something else, leading to misleading highlighting, especially on that regex

    For reference to those unfamiliar with ruby syntax, this is how it's supposed to be, curtesy of VSC:

  • JonnyMacJonnyMac Posts: 9,159
    edited 2021-12-12 13:58

    I would be happy if the code block would cleanly display in a monospaced font without the attempt to do syntax highlighting. Since the latter doesn't work well (in forum posts), it's very distracting.

  • Doing highlighting like literally every other markdown-based website, that is, only when given an explicit language hint, would be ideal:

    ```
    Plain code block!
    ```

    and

    ```spin
    CON
    _clkmode = xtal1 | pll16x
    _xinfreq = 5_000_000
    '' Spin code block!
    ```

  • Cluso99Cluso99 Posts: 18,069

    I’m with Jon. No need for highlighting.

    I’d rather just be able to click the code icon to insert the back ticks correctly and paste the code in mono spaced font.

    And, spend time fixing the forum bugs. It has those nasty pauses where you cannot do anything but wait.

  • I agree. If I want perfect highlighting, I'll copy and paste the text into Propeller Tool. That said, the highlighting that exists now seems pretty universal, and I have no objection to it.

    -Phil

  • jmgjmg Posts: 15,175
    edited 2021-12-13 01:47

    italic test one line

    code

    italic
    test
    four
    lines

    Italics seems to be a lottery, and the hidden * codes are risky, in that they can corrupt postings
    it seems embedded * can trigger italics, and delete the * ?

    maths formula
    (145102^32/(429496710M))

    exactly the same as code
    (14510*2^32/(4294967*10M))

    If syntax highlighting is erratic, it is better to disable it.

  • Definitely! If syntax highlighting alters the content of a code block, and not just its appearance, it should be disabled now.

    -Phil

  • Sigh.
    That's not syntax highlighting, that's just markdown parsing. Slightly crummy markdown parsing, but that's how it works on literally every website ever. Yes, it messes up maths if you're not careful. If you need something to not be parsed,
    a) put it in a code block
    b) escape the formatting character with a backslash
    c) just put whitespace around the characters that would cause a markdown span, they only parse when next to a "normal" character

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2021-12-13 03:19

    Markdown, or any other formatting, shouldn't be parsed in code blocks, period. We had the same problem with bbcode and [i] subscripts.

    -Phil

  • jmgjmg Posts: 15,175

    @Wuerfel_21 said:
    Sigh.
    That's not syntax highlighting, that's just markdown parsing. Slightly crummy markdown parsing, but that's how it works on literally every website ever. Yes, it messes up maths if you're not careful.

    Hmm... I've just checked that maths in 3 other forums, and none of them mangle it, like the Parallax forum does.

  • Wuerfel_21Wuerfel_21 Posts: 5,106
    edited 2021-12-13 12:05

    @"Phil Pilgrim (PhiPi)" said:
    Markdown, or any other formatting, shouldn't be parsed in code blocks, period. We had the same problem with bbcode and [i] subscripts.

    -Phil

    No one said that anything was being parsed inside a code block. and infact, that does *not* happen. (That is also the reason why @user references aren't links anymore, because those did parse inside code blocks for some reason)

    @jmg said:

    @Wuerfel_21 said:
    Sigh.
    That's not syntax highlighting, that's just markdown parsing. Slightly crummy markdown parsing, but that's how it works on literally every website ever. Yes, it messes up maths if you're not careful.

    Hmm... I've just checked that maths in 3 other forums, and none of them mangle it, like the Parallax forum does.

    That's just because they use BBCode or something. That's just the tradeoff of intuitive formatting vs. mangling oddball sequences that probably belong in a code block to begin with.

    That same "markdown parser chokes on math" issue manifests on a large number of popular websites, it's just a normal thing:
    reddit: (Nice superscripts though, haha)
    discord:
    github:

    and probably a hundred more.

  • This markdown thing tries to be super intelligent. Unfortunately it is not.
    So it should be switched of by default.

  • Cluso99Cluso99 Posts: 18,069

    @Wuerfel_21 said:

    ...

    No one said that anything was being parsed inside a code block. and in fact, that does *not* happen. (That is also the reason why @user references aren't links anymore, because those did parse inside code blocks for some reason)

    ...

    Why then when I post code inside the 3 backticks it converts some of my strings to italics, bold, etc. It's the markdown code that is being interpreted isn't it???

  • @Cluso99 said:

    @Wuerfel_21 said:

    ...

    No one said that anything was being parsed inside a code block. and in fact, that does *not* happen. (That is also the reason why @user references aren't links anymore, because those did parse inside code blocks for some reason)

    ...

    Why then when I post code inside the 3 backticks it converts some of my strings to italics, bold, etc. It's the markdown code that is being interpreted isn't it???

    That's the syntax highlighting trying to guess what language it is and applying highlighting based on that grammar. Yes, that is obnoxious and yes that is what i'm complaining about.

Sign In or Register to comment.