News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Tt tags not same as Courier New

Started by probeman, November 26, 2024, 08:46:12 PM

Previous topic - Next topic

probeman

I recently upgraded to 2.1.4 and previously we made a lot of use of the Tt tag to show non-proportionally spaced text:

ELEM:     SiO2     FeO     MgO   Al2O3     H2O       O   SUM 
    11  32.276   -.017  37.025  18.110  12.930    .000 100.324
    12  32.638    .034  35.687  18.295  12.969    .000  99.623
    13  32.689    .018  35.127  18.654  12.985    .000  99.473
    14  32.372   -.012  37.024  18.481  12.925    .000 100.789
    15  32.660    .013  36.367  18.637  12.944    .000 100.621

AVER:   32.527    .007  36.246  18.435  12.950    .000 100.166
SDEV:     .189    .022    .836    .233    .026    .000    .591
SERR:     .085    .010    .374    .104    .012    .000
%RSD:      .58  300.40    2.31    1.26     .20  -70.71


The above text using Courier New looks like it's NOT proportionally spaced right? The columns line up, right? But when I go back into the post to edit a typo, it changes to this:

ELEM:    SiO2    FeO    MgO  Al2O3    H2O      O  SUM 
    11  32.276  -.017  37.025  18.110  12.930    .000 100.324
    12  32.638    .034  35.687  18.295  12.969    .000  99.623
    13  32.689    .018  35.127  18.654  12.985    .000  99.473
    14  32.372  -.012  37.024  18.481  12.925    .000 100.789
    15  32.660    .013  36.367  18.637  12.944    .000 100.621

AVER:  32.527    .007  36.246  18.435  12.950    .000 100.166
SDEV:    .189    .022    .836    .233    .026    .000    .591
SERR:    .085    .010    .374    .104    .012    .000
%RSD:      .58  300.40    2.31    1.26    .20  -70.71

If I don't "Modify" the post any further, it stays non-proportionally spaced, but as soon as I go back in to edit the post in any way, it changes to proportionally spaced text even though I'm still using the Courier New tag!

How can this be fixed so text using Courier New stays non-proportionally spaced so the columns still line up?

Aleksi "Lex" Kilpinen

I would probably use  [pre] [/pre]


[pre]

ELEM:     SiO2     FeO     MgO   Al2O3     H2O       O   SUM 
    11  32.276   -.017  37.025  18.110  12.930    .000 100.324
    12  32.638    .034  35.687  18.295  12.969    .000  99.623
    13  32.689    .018  35.127  18.654  12.985    .000  99.473
    14  32.372   -.012  37.024  18.481  12.925    .000 100.789
    15  32.660    .013  36.367  18.637  12.944    .000 100.621

AVER:  32.527     .007  36.246  18.435  12.950    .000 100.166
SDEV:    .189     .022    .836    .233    .026    .000    .591
SERR:    .085     .010    .374    .104    .012    .000
%RSD:     .58   300.40    2.31    1.26     .20  -70.71

[/pre]


Becomes


ELEM:     SiO2     FeO     MgO   Al2O3     H2O       O   SUM 
    11  32.276   -.017  37.025  18.110  12.930    .000 100.324
    12  32.638    .034  35.687  18.295  12.969    .000  99.623
    13  32.689    .018  35.127  18.654  12.985    .000  99.473
    14  32.372   -.012  37.024  18.481  12.925    .000 100.789
    15  32.660    .013  36.367  18.637  12.944    .000 100.621

AVER:  32.527     .007  36.246  18.435  12.950    .000 100.166
SDEV:    .189     .022    .836    .233    .026    .000    .591
SERR:    .085     .010    .374    .104    .012    .000
%RSD:     .58   300.40    2.31    1.26     .20  -70.71


And this matches what you see in the post editor.

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

probeman

ELEM:      Si      Fe      Mg      Al      O      H  SUM  
    6  15.343  -.010  21.286  9.582  51.816  1.451  99.469
    7  15.022    .060  20.422  9.740  51.816  1.451  98.511
    8  15.408    .048  21.492  9.958  51.816  1.451 100.173
    9  15.131    .053  21.802  9.708  51.816  1.451  99.961
    10  15.157    .001  20.113  9.587  51.816  1.451  98.125


Above is with pre tag. Doesn't seem to work.

Arantor

They're all using Courier New, I don't think that's your problem.

In fact, I'm sure it isn't. The lines that are off are off specifically on the spacing, even though it's the same number of spaces.

This is a massively long running battle we have had between HTML and browsers because browsers collapse groups of spaces together by default. SMF does a lot to preserve that (always has)

The tt bbcode was *never* designed to support your use case. The fact it worked was basically a fluke and mostly because of, actually, the rest of the system doing space preservation for you.

pre is the correct tag for this because it has specific *additional* rules about not messing with spacing.

When you say you're correcting a typo, what *exactly* did you change? (Believe it or not this might well matter.) Also, quick edit or full edit? When you demo it in the first post, did you edit the first block of text or just the second?
Holder of controversial views, all of which my own.


probeman

Interesting.

I didn't realize that it's not an issue of non-proportionaly vs. proportional text.   Which is what I thought the Tt tag was all about.

It seems to be an issue of the browser removing, but also sometimes adding, a space here or there. As long as I paste my formatted text using the pre tag it seems to stay the way it was even if it's edited. Didn't realize the browser was messing with the spaces.

Thanks a bunch, this really helped.

sudoku

probeman, are you using only spaces (char 0x20) or combining with tab (char 0x09) usage? This might be another thing to look at.

probeman

Quote from: sudoku on November 27, 2024, 11:53:14 AMprobeman, are you using only spaces (char 0x20) or combining with tab (char 0x09) usage? This might be another thing to look at.

Only spaces, but I know what you mean.  Let's not get into the "Silicon Valley" spaces vs tabs thing!!!   

 ;D

sudoku

Probeman, like this...


First guy in first pic, "spaces"
Second guy in first pic, "tabs"

Third guy in second pic "both"

Third pic, result.

;D
@ mods, sorry for the detour.

Arantor

Quote from: probeman on November 27, 2024, 11:58:15 AM
Quote from: sudoku on November 27, 2024, 11:53:14 AMprobeman, are you using only spaces (char 0x20) or combining with tab (char 0x09) usage? This might be another thing to look at.

Only spaces, but I know what you mean.  Let's not get into the "Silicon Valley" spaces vs tabs thing!!!   

 ;D

There are also multiple kinds of spaces which is where it gets even more fun.

Specifically browsers by default are told "treat runs of spaces as if it's a single space" because that's the point of HTML, to write tags in to give the content semantic meaning.

SMF takes runs of sequential spaces (but not line breaks) and rewrites every other space as a "non breaking space". (For those playing along at home, this is Unicode U+A0 which varies in actual bytes depending on UTF-8 or whatnot. UTF-8 for this is 0xC2 0xA0, two bytes, yes.)

I checked the posts above, no tabs involved, only the runs of spaces being converted exactly as I'd expected.

The part I found most intriguing is that looking at it, the sequences of the before and after look the same. I also had to check silly things like em-dashes vs en-dashes (but they're all consistent too)

Really, tt is purely stylistic (inline text in a monotype, without hinting that white space should be correctly preserved) while pre is actually semantic and does indicate this.

I'm still not sure what happened here exactly, something feels off, but the pre tag is the correct canonical way to support this and it will consistently respect spaces in ways tt won't.
Holder of controversial views, all of which my own.


Advertisement: