MyBB Community Forums

Full Version: Code Blocks are messed up.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, the blocks below should contain lists of numbers aligned on the decimal point:

    1.0
    1.0
   10.0
  100.0
 1000.0
10000.0
 1000.0
  100.0

They do work better in a PHP block, (except the first line is still messed up) but most of my users aren't posting PHP so they don't think to use that block and the the syntax coloring is a distraction.

    1.0
    1.0
   10.0
  100.0
 1000.0
10000.0
 1000.0
  100.0


Oh and putting in a blank first line (or two as I've done here) doesn't fix the first line issue:



    1.0
    1.0
   10.0
  100.0
 1000.0
10000.0
 1000.0
  100.0


But some visible text will

Some random text to make things work
    1.0
    1.0
   10.0
  100.0
 1000.0
10000.0
 1000.0
  100.0


Any ideas how to fix this?
see mycode_parse_code in inc/class_parser
Seeing if I can post this....

Well apparently, I can make simple text replies but once I try to post something more complex with PHP snippets from the file you mentioned, I get a page that says

"One more step
Please complete the security check to access mybb.com
Enter above text"

But there's no obvious text to enter.

OK, so without posting any code, there's an obvious line in both the code parser and the php parser that wipes out any vertical or horizontal white space at the beginning. It seems like perhaps that line should completely go away or at least have the horizontal white space chars removed so it leaves them alone.

Later, there's a line that converts ordinary spaces to non-breaking spaces, but oddly, it only does this when there are pairs of them so any odd number of spaces is not completely translating. So that seems like an easy fix but given that replacing one a time is more obvious/simply/short anyway, I can't help but wonder if I am missing something - ie is there some subtle bug that someone already fixed by replacing them only in pairs?
(2014-01-06, 08:42 PM)Dave H Wrote: [ -> ]Later, there's a line that converts ordinary spaces to non-breaking spaces, but oddly, it only does this when there are pairs of them

That's because traditionally, HTML condenses <big wad of whitespace> to <single space>. In theory you could even get away with replacing only every other space with &nbsp; instead of both like the code currently does.

Unfortunately in this case it seems a single space after a newline is being eaten.
OK, so it seems like translating one space at a time should fix most of the problem, then there's that first line which replaces all leading tabs, spaces, Nulls, etc. with just the initial tabs if any - and only if they precede other whitespace characters. Any thoughts on that one? My inclination is to get rid of it entirely, but then getting rid of something that filters out nulls does frighten me a bit, but then it's only filtering nulls which happen to be in leading white space on the first line.

Odd that it wants to keep early tabs - though not any that appear after any spaces or newlines etc. Perhaps I just don't understand what's really going on on that one.

And then the whole business of translating tabs to nothing in a temp string (original) and then returning if that's empty... is that just to prevent people from posting code blocks full of whitespace - even if that's what they want to post? Or is there something I don't understand.