[code][/code] strips leading spaces

Let us know how we are doing -
Post Reply
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

[code][/code] strips leading spaces

Post by huw »

For example

Code: Select all

 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?
User avatar
Hagar Delest
Moderator
Posts: 32655
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

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

Post by Hagar Delest »

Code: Select all

Start of the line
   2 spaces indent here
No indent
      6 spaces indent here
Seems to work fine for me.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Hagar Delest
Moderator
Posts: 32655
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

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

Post by Hagar Delest »

huw wrote:For example

Code: Select all

    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:
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Bhikkhu Pesala
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

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

Post by Bhikkhu Pesala »

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
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

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

Post by huw »

Code: Select all

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).
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

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

Post by acknak »

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

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

    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
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

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

Post by huw »

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

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

 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

Zero trailing spaces
One 
Two  
Three   
Four    
Five     
That seems fine for me.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

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

Post by acknak »

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

<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
DrewJensen
Volunteer
Posts: 1734
Joined: Sat Oct 06, 2007 9:01 pm
Location: Cumberland, MD - USA

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

Post by DrewJensen »

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

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

    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

sub test
    dim a
    dim b

    if a then 
        print b
    end if
end sub
Use tabs

Code: Select all

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
Post Reply