tab characters converting to spaces in codebox

Discuss issues and requests related with the forum software
guest3456
Posts: 3162
Joined: 09 Oct 2013, 10:31

tab characters converting to spaces in codebox

08 Aug 2014, 10:46

A codebox should represent the literal text without any formatting changes

when I posted the result of a KeyHistory command, the columns weren't aligned:
http://ahkscript.org/boards/viewtopic.p ... 517#p23517

It looks like the tabs are being converted to spaces

example:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
A0  02A	 	d	4.69	LShift         	New AutoHotkey Script.ahk - Notepad
41  01E	 	d	0.25	A              	
41  01E	 	u	0.14	A              	
A0  02A	 	u	0.17	LShift  
There is supposed to be one tab char between each of these words: "Type Up/Dn Elapsed"

In the post editor, I am seeing one tab char. But when posted, I see spaces

kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: tab characters converting to spaces in codebox

08 Aug 2014, 11:30

I'm not sure if replacing tabs with spaces is necessary for the codeboxes. I'm not familiar with their inner workings.

But, I believe the difference in spacing is because Notepad and the Key History window treat tabs as being 8 characters wide. Whereas this site treats a tab as being four characters wide.
i.e. typing three characters then tab in Notepad produces a "tab" 5 characters in width.

Code: Select all

123     9
123456789
typing three characters then tab in codeboxes produces a "tab" 1 character in width.

Code: Select all

123	5
12345
and code boxes that aren't code=autohotkey behave different than both.

Code: Select all

123	7
1234567
1234	8
12345678
12345	9
123456789
guest3456
Posts: 3162
Joined: 09 Oct 2013, 10:31

Re: tab characters converting to spaces in codebox

08 Aug 2014, 12:51

kon wrote: i.e. typing three characters then tab in Notepad produces a "tab" 5 characters in width.
Correct. In Notepad, type "123<tab>9" and then on the next line, "123456789", and then paste it in a codebox.

In Notepad, it looks like this:

Code: Select all

123<tab>9
123456789
In the reply editor, you will correctly see one tab character after you paste it. But after you post, the tab gets converted into 3 spaces:

Code: Select all

123	9
123456789
This is no good.

Same as in the OP. The tabs between the words "Type Up/Dn Elapsed" got converted into 3 spaces

just me
Posts: 7747
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: tab characters converting to spaces in codebox

08 Aug 2014, 15:15

How many average character widths should one <tab> be? A <tab> hasn't a fixed width.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

08 Aug 2014, 16:56

Usually, it's between 4 and 8.
lexikos
Posts: 7185
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: tab characters converting to spaces in codebox

08 Aug 2014, 21:02

IE and Chrome on my system appear to render tabs in <pre> equivalent to 8 spaces. While it might be useful for formatting, I don't think it would look good for actual code (for instance, copied from a typical programmers editor which has tab size set to <= 4). However, as I use spaces, I don't particularly care.

But are tabs rendered consistently at 8 character intervals? I think that would be more important.

It seems support for specifying tab size in CSS is experimental.
User avatar
tank
Posts: 2855
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: tab characters converting to spaces in codebox

09 Aug 2014, 14:41

right and then we have to look at if the font is monospace or not
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
lexikos
Posts: 7185
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: tab characters converting to spaces in codebox

09 Aug 2014, 23:35

Huh? Of course it's monospace.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

17 Oct 2014, 01:02

Fixed a possibly related issue. see http://ahkscript.org/boards/viewtopic.p ... 389#p28278
joedf wrote:Ahh ha! FIXED! I have found the problem. Geshi/codebox isnt correctly converting the spaces to &nbsp; And html ignores 2 explicit consecutive spaces and treats as them 1 UNLESS we are in a <pre> tag.. So the quick fix what to change the opening/closing <div> tags to <pre> tags. Anyway, <pre> is the recommended one for code...
User avatar
lmstearn
Posts: 392
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: tab characters converting to spaces in codebox

14 Aug 2016, 10:30

Wonder if this affects any code posted before the fix? ---
If that is related at all to the problem of lines containing only <CR LF> given an extra space in forum code?
Heck, not a major drama if the compiler can be made to ignore a line containing space(s) only. :)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

14 Aug 2016, 10:39

I'm not sure. I believe it affects posts after the fix.
Either way, editing old posts can be used to fix this if this is the case.
User avatar
lmstearn
Posts: 392
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: tab characters converting to spaces in codebox

17 Aug 2016, 01:49

joedf wrote:I'm not sure. I believe it affects posts after the fix.
Either way, editing old posts can be used to fix this if this is the case.
Definitely a problem with Edge. Even Internet Explorer works. Very unusual.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
lexikos
Posts: 7185
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: tab characters converting to spaces in codebox

17 Aug 2016, 02:02

lmstearn is talking about a different issue than the one this topic was created for - one that hasn't been fixed.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

17 Aug 2016, 10:42

I see. So when copy pasting code from the forum, you are getting an error because of 0xA0 spaces.
User avatar
lmstearn
Posts: 392
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: tab characters converting to spaces in codebox

18 Aug 2016, 07:30

Yes, although that will probably want to be verified by other Edge users just in case this system is borked. :)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
lexikos
Posts: 7185
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: tab characters converting to spaces in codebox

18 Aug 2016, 18:40

See also Ignore a Line Containing Spaces Only? · Issue #59.

The problem is not limited to Edge; it is just very unlikely to cause any problems in other browsers. This is the most likely problem scenario I can think of:

Code: Select all

x =
(RTrim0
line one

line two
)
Loop Parse, x, `n
    if (A_LoopField != "")
        MsgBox % A_LoopField
If you copy and paste from the code box with any browser (I have tested Chrome), there will be an extra (empty) MsgBox that isn't shown by the original code. You can get the original code by quoting the post.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

18 Aug 2016, 21:56

Quite possibly a bug inside Codebox Plus that's not too hard to fix...
A quick look, I think it can be done here: https://github.com/o0johntam0o/phpBB-Ex ... stener.php
I'll get to it on my off days :)
lexikos
Posts: 7185
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: tab characters converting to spaces in codebox

18 Aug 2016, 22:41

I don't see any relevant use of &nbsp; in that file.

It's probably here - "Make lines have at least one space in them if they're empty" shouldn't be done when $this->header_type == GESHI_HEADER_PRE || $this->header_type == GESHI_HEADER_PRE_VALID.

Notice that I linked to the version of the extension that I put into use, not the original. You might want to check whether any changes have been made on the server, and if so, push them to GitHub.

Thanks.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

19 Aug 2016, 08:55

Thanks for the heads up. I've verified that the files are identical with the exception of EOL/Blank lines.
Commit 6ad2bdd.
User avatar
joedf
Posts: 7894
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: tab characters converting to spaces in codebox

19 Aug 2016, 09:40

Changed it to '&#32;' instead, last commit was causing blank pages.
commit 5453741.

Edit: &nbsp; still appearing, tested here: https://autohotkey.com/boards/viewtopic ... 13#p104513
Must be somewhere else... with grep, only geshi.php seems to be relevant.

Return to “Forum Issues”

Who is online

Users browsing this forum: No registered users and 3 guests