[code][/code] strips leading spaces

Let us know how we are doing -

[code][/code] strips leading spaces

Postby huw » Wed Dec 19, 2007 5:19 pm

For example
Code: Select all   Expand viewCollapse view
This sentence should have a leading space.
This shouldn't.
This should.
The spaces are still there if the post is quoted or edited, but they never display. Does BBCode have a <PRE> tag?

Edit: the above is a trivial example, but what about indented code?
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: [code][/code] strips leading spaces

Postby Hagar Delest » Thu Dec 20, 2007 12:07 am

Code: Select all   Expand viewCollapse view
Start of the line
   2 spaces indent here
No indent
      6 spaces indent here

Seems to work fine for me.
AOO 4.1.6 on Xubuntu 18.10 and 4.1.5 on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28390
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [code][/code] strips leading spaces

Postby Hagar Delest » Thu Dec 20, 2007 12:09 am

huw wrote:For example
Code: Select all   Expand viewCollapse view
    This sentence should have a leading space.
This shouldn't.
    This should.
The spaces are still there if the post is quoted or edited, but they never display. Does BBCode have a <PRE> tag?

Edit: the above is a trivial example, but what about indented code?

NB: If I add spaces in your code, it works :shock:
Conclusion : my keyboard is better than yours :mrgreen:
AOO 4.1.6 on Xubuntu 18.10 and 4.1.5 on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28390
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [code][/code] strips leading spaces

Postby Bhikkhu Pesala » Thu Dec 20, 2007 12:52 am

If you can keep your head when all about you
     Are losing theirs and blaming it on you.

If you can meet with Triumph and Disaster
     And treat those two impostors just the same.

If you use Opera browser,
     you can add a shortcut to insert five hard spaces [0160] at once.
     That works in most forums.

     space ctrl = Insert, "     "

If you can fill the unforgiving minute
     With sixty seconds' worth of distance run,
Yours is the Earth and everything that's in it,
     And - which is more - you'll be a Man, my son!
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
User avatar
Bhikkhu Pesala
 
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Re: [code][/code] strips leading spaces

Postby huw » Thu Dec 20, 2007 11:23 am

Code: Select all   Expand viewCollapse view
Zero leading spaces
One
  Two
   Three
    Four
     Five

Now will you all admit there's nothing wrong with my spacebar?! Or shall I go back and edit the thread subject to read "{code}{/code} strips single leading space"* so you all look crazy, not me?

So, only a single leading space is stripped, any more and they're allowed. It still caught me out though.

*Can BBCode tags be escaped? Backslash doesn't seem to work for me (or may be that key is dodgy on my keyboard).
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: [code][/code] strips leading spaces

Postby acknak » Thu Dec 20, 2007 5:31 pm

It may not be your keyboard, but something very odd is going on.

Here's what I get if I reconstruct your entry (in my text editor) based on what you wrote, then paste that into a pair of code tags:
Code: Select all   Expand viewCollapse view
Zero leading spaces
One
  Two
   Three
    Four
     Five

So it's the same result for me.

Here's what I get when I use the "SELECT ALL" link; copy & paste from your example:
Code: Select all   Expand viewCollapse view
    Zero leading spaces
    One
      Two
       Three
        Four
         Five

There are four leading spaces on the first two lines, six on the next line ("Two"), 7, 8 and 9 on the last three (respectively).

Copying the one I typed out gives me back the same thing I get from yours. Copying the one I copied from yours adds four more spaces at the start.

Uggh. Obviously this needs to be fixed: the [ code][/code]* tags need to be reliable, both for display and for copying.

* In phpBB on oooforum, you could escape any special character by using a numeric entity: &#91; but that doesn't work in phpBB3. I can't find any way to escape the bbcode tags here. You can slightly mangle the tags and they will be left alone.
PS: I'm using Mozilla Seamonkey on Linux.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [code][/code] strips leading spaces

Postby huw » Thu Dec 20, 2007 5:59 pm

acknak wrote:It may not be your keyboard, but something very odd is going on.

Here's what I get if I reconstruct your entry (in my text editor) based on what you wrote, then paste that into a pair of code tags:
Code: Select all   Expand viewCollapse view
Zero leading spaces
One
Two
Three
Four
Five

So it's the same result for me.

Here's what I get when I use the "SELECT ALL" link; copy & paste from your example:
Code: Select all   Expand viewCollapse view
Zero leading spaces
One
Two
Three
Four
Five

There are four leading spaces on the first two lines, six on the next line ("Two"), 7, 8 and 9 on the last three (respectively).

Copying the one I typed out gives me back the same thing I get from yours. Copying the one I copied from yours adds four more spaces at the start.

Uggh. Obviously this needs to be fixed: the [ code][/code]* tags need to be reliable, both for display and for copying.

Yikes! Quoting hoses the lot!

I don't have any problem with the SELECT ALL - the displayed number of spaces are copied and pasted fine (the display, and therefore copy & paste, being wrong regarding a single leading space). I'm using IE6 on XP. Anyone else care to help us eliminate OS, browser, or forum software as the problems' sources?

In light of potential trailing space problems, a test:

Code: Select all   Expand viewCollapse view
Zero trailing spaces
One
Two 
Three   
Four   
Five     

That seems fine for me.
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: [code][/code] strips leading spaces

Postby acknak » Thu Dec 20, 2007 7:43 pm

FWIW, I see exactly the same errors if I use Firefox.

The trailing spaces seem fine for me (I still get the extra four spaces at the start of each line).

Interestingly, if I paste into the Mozilla HTML editor (so the phpBB html is preserved--presumably), I get this:
Code: Select all   Expand viewCollapse view
<dl class="codebox">
<dd><code>Zero leading spaces<br>
One<br>
&nbsp; Two<br>
&nbsp; &nbsp;Three<br>
&nbsp; &nbsp; Four<br>
&nbsp; &nbsp; &nbsp;Five<br>
</code></dd>
</dl>

So the extra leading spaces are probably coming from Mozilla's attempt to "indent" a "DL" (Dictionary List).

It is very surprising to me that they would try to use such a list element to hold "preformatted" content. Maybe it's not quite safe to let "J. Random User" insert just any preformatted text; I don't know.

Whatever the intent, this isn't acceptable (IMO): we need to be able to accurately display snippets that can be copied out accurately. Having to attach a file just for that purpose is way to much trouble. I don't mean it's a crisis of course, but it seems like something that we really need to be able to do. It's certainly a regression from phpBB2.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [code][/code] strips leading spaces

Postby DrewJensen » Thu Dec 20, 2007 7:51 pm

acknak wrote:It may not be your keyboard, but something very odd is going on.

Here's what I get if I reconstruct your entry (in my text editor) based on what you wrote, then paste that into a pair of code tags:
Code: Select all   Expand viewCollapse view
Zero leading spaces
One
  Two
   Three
    Four
     Five

So it's the same result for me.

Here's what I get when I use the "SELECT ALL" link; copy & paste from your example:
Code: Select all   Expand viewCollapse view
    Zero leading spaces
    One
      Two
       Three
        Four
         Five

There are four leading spaces on the first two lines, six on the next line ("Two"), 7, 8 and 9 on the last three (respectively).

Copying the one I typed out gives me back the same thing I get from yours. Copying the one I copied from yours adds four more spaces at the start.

Uggh. Obviously this needs to be fixed: the [ code][/code]* tags need to be reliable, both for display and for copying.

* In phpBB on oooforum, you could escape any special character by using a numeric entity: &#91; but that doesn't work in phpBB3. I can't find any way to escape the bbcode tags here. You can slightly mangle the tags and they will be left alone.
PS: I'm using Mozilla Seamonkey on Linux.


Use spaces
Code: Select all   Expand viewCollapse view
sub test
    dim a
    dim b

    if a then
        print b
    end if
end sub


Use tabs
Code: Select all   Expand viewCollapse view
sub test
   dim a
   dim b

   if a then
      print b
   end if
end sub


I am using FireFox under XP with my default encoding set to UTF-8..not that this should matter.

I'll switch over to Linux here in just a bit and try it also.
Former member of The Document Foundation
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
User avatar
DrewJensen
Volunteer
 
Posts: 1734
Joined: Sat Oct 06, 2007 9:01 pm
Location: Cumberland, MD - USA


Return to Site Feedback

Who is online

Users browsing this forum: No registered users and 2 guests