I have a problem with [code] and [php] blocks, and that problem does not entail the way this site looks, and as such - has nothing to do with the layout. I'm saying this because I know at least one of you are going to come in here yelling "No layout suggestions! It's against the rules!". I know that. As aforementioned, I believe the current code blocks are not functioning as they rightly should.
The problems I've identified are as follows:
These prove to be a pain in the ass. They really do. One other thing, and a rather personal one, as it doesn't really matter as much, is having to scroll down a very tiny viewport to see large pieces of code.
Here's what I believe should be changed:
One:
Use one consistent tag. Instead of [code] and [php], why not [code=php]? This will make it more maintainable for syntax highlighting other languages - [code=ruby], [code=python], etc. Adding support for syntax highlighting other languages will not be hard, either. There are so many client-side (and server-side) syntax highlighting libraries out there that cover hundreds of languages - and all they look for are CSS class names on HTML <code> or <pre> tags that match the language of the code in the code block. A few even automatically detect the syntax if no syntax is supplied. There are literally so many options - Google Code Prettify, Prism.js, Highlight.js, etc - and some of these libraries weigh in at under 2kb when minified and gzipped. So there really is no excuse.
Two:
A code block should not care what type of indentation the code included in the block uses, and as such, should not butcher the code therein if the syntax is not consistent with the code block's default nature. This is a standard part of any decent syntax highlighter library, so fixing number one should fix this anyway.
Three:
Adding a syntax highlighter library will add syntax highlighting support for many languages without much work involved, so fixing number one will fix this too, just like it'll fix number two. Wonderfully easy, right?
Four:
Remove this truncation. Why the hell is it even here in the first place? Am I being oblivious in thinking it's not needed? Seriously, answer me on this one - because I do not know any possible reason this is needed.
As for scrolling down large snippets of code in a tiny viewport - I don't mind it, but it sure would be SO much better not having to do that. I understand that you don't want posts to be too large on a screen (more thread pages = more bandwidth), otherwise you wouldn't have enabled [spoiler]s or made quotes automatically purge any nested quotes (if any), but, perhaps there can be a small compromise:
A simple little expand button. By default, [code] tags will have the same height viewport that they do now. But a button at the bottom with a tiny arrow pointing down or a plus icon, that, when clicked, expands the code block to the full length of the code. Of course this isn't necessary - I'm sure people would enjoy it though.
Oh, and a "select all" option that selects all of the code within a block for easy copying to clipboard. That's really all I have to say on the matter.
I hear it rumoured somewhere that this'll be too much work. If it is, and I offered to create a plugin that does this, would that make it easier on you, Omni?
The problems I've identified are as follows:
- Two different types: [code] and [php] (Why not one consistent option?)
- Indentation is malformed unless the code contained within is 2-space indented
- Only one syntax highlight option, and it highlights PHP properly, but not other languages
- Sometimes, code is truncated into shorter syntax - "bbbb" becomes just "b"
These prove to be a pain in the ass. They really do. One other thing, and a rather personal one, as it doesn't really matter as much, is having to scroll down a very tiny viewport to see large pieces of code.
Here's what I believe should be changed:
One:
Use one consistent tag. Instead of [code] and [php], why not [code=php]? This will make it more maintainable for syntax highlighting other languages - [code=ruby], [code=python], etc. Adding support for syntax highlighting other languages will not be hard, either. There are so many client-side (and server-side) syntax highlighting libraries out there that cover hundreds of languages - and all they look for are CSS class names on HTML <code> or <pre> tags that match the language of the code in the code block. A few even automatically detect the syntax if no syntax is supplied. There are literally so many options - Google Code Prettify, Prism.js, Highlight.js, etc - and some of these libraries weigh in at under 2kb when minified and gzipped. So there really is no excuse.
Two:
A code block should not care what type of indentation the code included in the block uses, and as such, should not butcher the code therein if the syntax is not consistent with the code block's default nature. This is a standard part of any decent syntax highlighter library, so fixing number one should fix this anyway.
Three:
Adding a syntax highlighter library will add syntax highlighting support for many languages without much work involved, so fixing number one will fix this too, just like it'll fix number two. Wonderfully easy, right?
Four:
Remove this truncation. Why the hell is it even here in the first place? Am I being oblivious in thinking it's not needed? Seriously, answer me on this one - because I do not know any possible reason this is needed.
As for scrolling down large snippets of code in a tiny viewport - I don't mind it, but it sure would be SO much better not having to do that. I understand that you don't want posts to be too large on a screen (more thread pages = more bandwidth), otherwise you wouldn't have enabled [spoiler]s or made quotes automatically purge any nested quotes (if any), but, perhaps there can be a small compromise:
A simple little expand button. By default, [code] tags will have the same height viewport that they do now. But a button at the bottom with a tiny arrow pointing down or a plus icon, that, when clicked, expands the code block to the full length of the code. Of course this isn't necessary - I'm sure people would enjoy it though.
Oh, and a "select all" option that selects all of the code within a block for easy copying to clipboard. That's really all I have to say on the matter.
I hear it rumoured somewhere that this'll be too much work. If it is, and I offered to create a plugin that does this, would that make it easier on you, Omni?


![[Image: 2QzRqrh.png]](https://i.imgur.com/2QzRqrh.png)

![[Image: Pi0HBk0.gif]](https://i.imgur.com/Pi0HBk0.gif)
![[Image: vgx9T6b.gif]](https://i.imgur.com/vgx9T6b.gif)
![[Image: HTdHLU5.png]](https://i.imgur.com/HTdHLU5.png)
