Code Tags and Opera 12

Continuing the discussion from Did you know… (about Discourse):

No, actually it adds the code thingie at the top of your post, and does not look once at the code you have posted and highlighted.

Maybe it works if you’ve only got code, but it breaks if you typed regular text first. This is consistently not working.

It appears the three backticks only works for one-liners: trying to do it for a block of code gives you a grey-highlighted space and then normal code.

test

    var rows = [],                                                              
        currentRow = [];                                                        
                                                                                
    list.map(function(i, li) {                                                  
        if (i % rowLength === 0 && i !== 0) {                                   
            rows.push(currentRow);                                              
            currentRow = [];                                                    
        }                                                                       
        currentRow.push(li);                                                    
    });                                                                         
    rows.push(currentRow);                                                      
                                                                                
    return rows;                                                                
}```

The code above is directly copied from my editor, which like many editors has tabs set to so-many spaces. In Javascript, that's one tab for 2 spaces (which means I hit Tab twice for 4 spaces total). This seems to make Discourse think I have code in code, removes the indentation I have for the list.map part, and highlights *that* as code and not the whole thing.

I hoped the three ticks would just be some kind of --force as in "yes I know you'll get it wrong so just trust me" like the old code blocks did in vBull.

Is there another way to override this?

Lastly, in order to use the mouse to place my cursor where I want to type or edit, I must first raise the whole edit bar to the full-page height, otherwise it will always jump the scrollbar to the top instead of where I've placed it. This is probably a deliberate onfocus setup and I doubt this can be changed within Discourse.  But it's vaguely annoying, as editing a long post at the end means arrowing down a long time (pagedn works but End doesn't).

Ah, it actually does, but you need a blank line between your text and the start of your code (added newlines to prior Did you know…), example:

`function generateRows(list, rowLength) { 
var rows = [], 
currentRow = [];

list.map(function(i, li) {                                                  
    if (i % rowLength === 0 && i !== 0) {                                   
        rows.push(currentRow);                                              
        currentRow = [];                                                    
    }                                                                       
    currentRow.push(li);                                                    
});                                                                         
rows.push(currentRow);                                                      

return rows;
}

Also, I copied and pasted from the prior output which is why all formatting was lost (not sure if the formatting remains lost when using tabs…so I reserve that statement for a later example ;))

Use Ctrl + End

1 Like