PDA

View Full Version : Table Tag



TosaInu
12-14-2004, 19:36
Credit to Mouzafphaerre for this.

Table tag. Table tags are normally dangerous for forum layouts, for example because it isn't closed properly. This hack does not have that unwanted side effect as far as I can see. Usage may be a bit confusing at first, but I guess anyone can get used to it. The hack is still under development, so it may become more userfriendly.

It works pretty simple {table} or {table 1 2 3} is the opening tag and {/table} closes it. Difference is tableborder, padding and spacing (use numbers to your liking). Each new line is a row. A | makes a new cell. There are also 7 styles that can be used for each line. Use them like this 5^ . Style 7 is default and can be omited. Use [ instead of { and ] instead of }.

{table 1 3 0}
1|2|test 16798789789797979799879797979|4|5|6|7
1^~right with colspan
2^333|=center with colspan
3^1|2|left with colspan
4^1|~center without colspan|3|4|5|6|7
5^1|blablabla|3|4|5
6^1|2|3|4|5|6|7
{/table}

Gives


1|2|test 16798789789797979799879797979|4|5|6|7
1^~right with colspan
2^333|=center with colspan
3^1|2|left with colspan
4^1|~center without colspan|3|4|5|6|7
5^1|blablabla|3|4|5
6^1|2|3|4|5|6|7


Just {table}


1|2|test 16798789789797979799879797979|4|5|6|7|8777777
1^~right with colspan
2^333|=center with colspan
3^1|2|left with colspan
4^1|~center without colspan|3|4|5|6|7
5^1|blablabla|3|4|5
6^1|2|3|4|5|6|7


I've briefly tested it and this hack seems to be ok, it will be removed however until /unless it gets improved when there are unwanted effects.

Feel free to experiment away and have fun.

TosaInu
12-14-2004, 20:06
Note: the WYSIWYG mode does not allow to edit the table after it's posted, that happens with some other code too. Use the normal editor then (UserCP/edit options).

therother
12-14-2004, 20:57
Just playing about with it now - looks excellent. A great addition for presenting research data. Thanks very much Tosa for the work, and Mouzafphaerre for the idea. :bow:

therother
12-15-2004, 01:48
A question: I'm trying to format this data into a table. I've chosen {table 1 2 2} as my options, and each entry is centred with no style. The problem seems to be that every so often the "=" appears or there is a space in between figures. I've manually checked through the table (the data was generated by a script) but I can find no obvious reason for the aberrations. Any ideas on what is causing it? I fiddled with the settings a little, but no joy.

Edit: Removed one decimal place in the 2nd column of affected rows, and the problem seems to vanish. Very curious...

Oh well, they were extraneous digits anyway.

3^=Name|=Dist|=Dist-10|=Game %|=WithRules|=Diff|=CurForm|=Diff2|=Dist|=Dist-10
2^=Tarentum|=0|=-10|=0|=0|=0|=0|=0|=0|=-10
2^=Croton|=6|=-4|=0|=0|=0|=0|=0|=6|=-4
2^=Apollonia|=10|=0|=0|=0|=0|=0|=0|=10|=0
2^=Salona|=12.64911064|=2.649110641|=0|=0|=0|=0|=0|=12.64911064|=2.649110641
2^=Capua|=13|=3|=0|=0|=0|=0|=0|=13|=3
2^=Messana|=14.4222051|=4.422205102|=0|=0|=0|=0|=0|=14.4222051|=4.422205102
2^=Cro-Cap|=16.2788206|=6.278820596|=5|=5|=0|=5|=0|=16.2788206|=6.278820596
2^=Thermon|=19.6977156|=9.69771560|=10|=10|=0|=5|=-5|=19.6977156|=9.697715604
2^=Syracuse|=20.61552813|=10.61552813|=10|=10|=0|=10|=0|=20.61552813|=10.61552813
2^=Rome|=20.61552813|=10.61552813|=10|=10|=0|=10|=0|=20.61552813|=10.61552813
2^=Larissa|=22.3606797|=12.36067977|=10|=10|=0|=10|=0|=22.36067977|=12.36067977
2^=Thessalonica|=24.51530134|=14.5153013|=15|=15|=0|=10|=-5|=24.51530134|=14.51530134
2^=Lilybaeum|=25|=15|=15|=15|=0|=15|=0|=25|=15
2^=Bylazora|=26.07680962|=16.076809|=15|=15|=0|=15|=0|=26.07680962|=16.07680962
2^=Ariminum|=26.17250466|=16.17250466|=15|=15|=0|=15|=0|=26.17250466|=16.17250466
2^=Corinth|=28.17800561|=18.17800561|=15|=20|=5|=15|=0|=28.17800561|=18.17800561
2^=Segestica|=28.46049894|=18.4604989|=15|=20|=5|=15|=0|=28.46049894|=18.46049894
2^=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif|=https://forums.totalwar.org/vb/images/smilies/misc/smile.gif

Mouzafphaerre
12-15-2004, 05:05
-
Many thanks for making my humble idea a reality, and with an ingenius hack, dear patron.

:bow:
_

Mouzafphaerre
12-20-2004, 22:56
-
Oh most honourable Tosa Inu sama,

It seems that the table tag has a problem with smiley text codes (eg. :bow:) but image tags work perfectly.

4^http://www.thelib.com/gallery/albums/userpics/sambow.gif

Also, is there a way to hack the each linebreak makes a new row rule to enable multiple lines per cell?
-

TosaInu
12-21-2004, 00:22
Hello Mouzafphaerre,

It's a hack made by JohnWoo, I only added it.

Smilycodes, ok will see. I assume you want more than one line in a cell?

Mouzafphaerre
12-21-2004, 20:08
-
Yes, more than a line per cell would be better. Smileycodes aren't as big a problem since they can always be inserted as images when necessary.
-

TosaInu
12-21-2004, 23:29
therother, seems that each cell is using = from a worksheet? I'm pretty sure that shouldn't be there (possibly only visible in the WYSIWYG editor).


A|1|2|3|4|5|6|7
B|1|2|3|4|Just continue typing in one cell and an extra line will be added when required Blablablablablablablablablablablablablablablablablablablablabla|6|7
C|1|2|3|4|5|~:)|7


It's not perfect (adds a space between bl and a near end) but it should do in some cases.

It's adding extra " with the smiley, I guess the textparser can be fixed for this.

Mouzafphaerre
12-22-2004, 05:36
-
Thank you very much Tosa. I believe I can hack the autobreaking lines with my own tricks for now. ~;)
-

therother
12-23-2004, 06:56
These are some entries that aren't formatted quite right -

2^=Thermon|=19.6977156|=9.697715604|=10|=10|=0|=5|=-5|=19.6977156|=9.697715604
2^=Larissa|=22.36067977|=12.36067977|=10|=10|=0|=10|=0|=22.36067977|=12.36067977
2^=Thessalonica|=24.51530134|=14.51530134|=15|=15|=0|=10|=-5|=24.
2^=Segestica|=28.46049894|=18.46049894|=15|=20|=5|=15|=0|=28.46049894|=18.46049894
The 1st, 3rd and 4th have the "=" displayed instead of aligning the text in the centre. The 2nd one is different - under the CufForm Column, 10 is displayed as 1 0 for some reason.

As a say above, removing any character on the left hand side of the aberation removes the problem.

Hmm, now this is curious: this is the code for the table, pasted into the standard editor from notepad:
3^=Name|=Dist|=Dist-10|=Game %|=WithRules|=Diff|=CurForm|=Diff2|=Dist|=Dist-10
2^=Thermon|=19.6977156|=9.697715604|=10|=10|=0|=5|=-5|=19.6977156|=9.697715604
2^=Larissa|=22.36067977|=12.36067977|=10|=10|=0|=10|=0|=22.36067977|=12.36067977
2^=Thessalonica|=24.51530134|=14.51530134|=15|=15|=0|=10|=-5|=24.
2^=Segestica|=28.46049894|=18.46049894|=15|=20|=5|=15|=0|=28.46049894|=18.46049894
Notice the spaces, and crucially the position of them. I wonder why this is?

TosaInu
12-23-2004, 10:40
Hello therother,

It's an odd thing, but try skipping the = signs in the input, they are not required.

therother
12-23-2004, 11:36
It's an odd thing, but try skipping the = signs in the input, they are not required.I don't think that it's the = sign that is causing the problem - the board seems to add a space into "words" over 60 characters in length:

For example:

1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 123456789012345678901234567890

There are no spaces in that number, yet one is added after the 60th character, and again after the 120th.

This explains the mysterious =, as the table was entered without spaces, as well as the odd spaces that appear in the table.

A "=" appears when the 60th character is after the division marker |, so something entered as "|=60" becomes "| =60", resulting in the = being displayed instead of centring the text.

A workaround would be to insert spaces before the |, and try not to use 60 digit numbers or 60 character words!

And so the hack itself is exonerated.

TosaInu
12-23-2004, 11:48
Yes, there's adding of spaces. That's something that showed up with the linebreak 'test'. Typing '=' signs in cells is redundant here as they are not required. It may not cause the problem, but the specific problem in above example can be avoided by deleting =.


3^Name|Dist|Dist-10|Game %|WithRules|Diff|CurForm|Diff2|Dist|Dist-10
7^Thermon|19.6977156|9.697715604|10|10|0|5|-5|19.6977156|9.697715604
7^Larissa|22.36067977|12.36067977|10|10|0|10|0|22.36067977|12.36067977
7^Thessalonica|24.51530134|14.51530134|15|15|0|10|-5|24.
7^Segestica|28.46049894|18.46049894|15|20|5|15|0|28.46049894|18.46049894

3^Name|Dist|Dist-10|Game %|WithRules|Diff|CurForm|Diff2|Dist|Dist-10
7^Thermon|19.6977156|9.697715604|10|10|0|5|-5|19.6977156|9.697715604
7^Larissa|22.36067977|12.36067977|10|10|0|10|0|22.36067977|12.36067977
7^Thessalonica|24.51530134|14.51530134|15|15|0|10|-5|24.
7^Segestica|28.46049894|18.46049894|15|20|5|15|0|28.46049894|18.46049894

therother
12-23-2004, 12:18
What you say is true. However, the ability to align text is useful, especially if there is a wide range of column widths.
e.g.
This is a wide column|Narrow
Narrow|narrow
=This is a wide column|=Narrow
=Narrow|=narrow
To me, the 2nd version just looks nicer, and is easier to read.

I still think the best solution, in terms of data fidelity, is to ensure that no entry is more than 60 characters in length, as this will eliminate both the extra spaces and any erroneously displayed alignment characters (i.e. = and/or ~).

For example, in the table without the = signs above, we have entries of

22. 36067977
2 8.46049894

Your eye can certainly compensate for these errors when reading, but if the table is presenting data to be copied and pasted by members, then 2 8.46049894 is not the same as 28.46049894, and you may not notice the spaces when you've just copied a 100x6 table!

Edit: This is a centred version of the table above, with a space inserted after the Game % entry. As the Column is 6 characters wide in any case, it makes no difference to the appearance of the table, as the extra space seems to be chopped off, i.e. it doesn't appear when you copy the table and paste it into a local application (e.g. a spreadsheet).

3^=Name|=Dist|=Dist-10|=Game %|=WithRules|=Diff|=CurForm|=Diff2|=Dist|=Dist-10
=Thermon|=19.6977156|=9.697715604|=10 |=10|=0|=5|=-5|=19.6977156|=9.697715604
=Larissa|=22.36067977|=12.36067977|=10 |=10|=0|=10|=0|=22.36067977|=12.36067977
=Thessalonica|=24.51530134|=14.51530134|=15 |=15|=0|=10|=-5|=24.
=Segestica|=28.46049894|=18.46049894|=15 |=20|=5|=15|=0|=28.46049894|=18.46049894

therother
01-26-2005, 20:26
I notice that a number of tables (including some in this thread) are now not being displayed correctly. Is this just a temporary glitch, or has the hack been removed?

Mouzafphaerre
01-27-2005, 04:24
-
It seems to have gone, hopefully not for the good.
-

therother
02-26-2005, 12:44
It seems to have gone, hopefully not for the good.I don't know if you've noticed, but it's back: apparently one of the patches overwrote the table tag code, but TosaInu managed to fix it. ~D

Mouzafphaerre
02-26-2005, 16:49
-
I noticed but was lazy to fix my comment. Hail Tosa! :knight:
-

TosaInu
02-26-2005, 19:59
Not so hail as I didn't even notice it was broken. Credit to therother for spotting it.

Mouzafphaerre
10-19-2005, 07:24
.
We have a situation sir: :charge:

...it breaks without editing after one viewing. I tried again in the same thread for a new post.

So a more detailed description:

I start a new topic, use the table code {table 1 3 0} to start and {/table} to end. Used only 2 columns, and used 4^ to highlight some rows.

I post the message, and it takes me to the post and the table looks fine. I either refresh the page or click on the topic again and the table code breaks. It looks like the exact code in the editor.

If I edit again in standard mode and save changes in fixes it again. However it breaks once again after I refresh the page. I can continue this cycle forever it seems.
Could it be related with the trouble with the code tag, as in both originating from the same glitch?
.

therother
10-19-2005, 13:30
Hmm, I have a few tables around the forums, and bar the new Table code being a bit more fastiduous about spaces, it seems to work pretty much the same as the old one.

Testing:

1|1
2|4
4^3|9
4|16
4^5|25
6|36
7|47


Edit: Hmm, odd. Disappeared on refresh. Doesn't happen with my table here. ~:confused:

TosaInu
10-19-2005, 13:38
Strange things.

TosaInu
10-19-2005, 13:39
1|1
2|4
4^3|9
4|16
4^5|25
6|36
7|47

TosaInu
10-19-2005, 18:35
Quick-fixed.

Craterus
10-19-2005, 19:22
=1|=1
=2|=4
4^=3|=9
=4|=16
4^=5|=25
=6|=36
=7|=47


bold

1|1
2|4
4^3|9
4|16
4^5|25
6|36
7|47


You know that 7(squared) is 49? Not 47. ~;)

TosaInu
10-19-2005, 23:08
Tables are now using an extra = in the option list table= x x x

therother
10-19-2005, 23:20
Also, if you just want a simple table, without the further settings, you have to add in the = as well.

e.g.
1|1
2|8
3|27

Gives:
1|1
2|8
3|27

Mouzafphaerre
10-20-2005, 05:18
.
https://forums.totalwar.org/vb/images/avatars/staff/m/admin/TosaInu.gif | :bow:
https://forums.totalwar.org/vb/images/avatars/mtw/mus/King/king53.gif | :bow:

.

TosaInu
10-20-2005, 10:33
Most credit goes to the genuine PHP coder who fixed it.

Mouzafphaerre
10-20-2005, 17:46
.
https://forums.totalwar.org/vb/images/avatars/staff/m/admin/TosaInu.gif | :bow:
https://forums.totalwar.org/vb/images/avatars/mtw/mus/King/king53.gif | :bow:
Genuine PHP coder | :bow:

.

therother
10-20-2005, 17:52
I agree with 1 & 3, even if the former protests. 2 did nothing but update a few tables. ~:)

Mouzafphaerre
10-21-2005, 01:48
.
ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968

ssfs | 2452345
asfasf | 6968
.

Mouzafphaerre
10-21-2005, 01:53
.
Weird...

ssfs | 2452345
asfasf | 6968
.

Mouzafphaerre
10-21-2005, 01:56
.
Well...


ssfs | 2452345
asfasf | 6968
asfasf | 6968

returns

ssfs | 2452345
asfasf | 6968
asfasf | 6968

while


ssfs | 2452345
asfasf | 6968
asfasf | 6968

returns

ssfs | 2452345
asfasf | 6968
asfasf | 6968

It seems 0 border is ignored if padding and spacing are 1, not 3 (didn't try 2).
.

Mouzafphaerre
10-21-2005, 01:59
.
Oops! Sorry...

asfdsdf|23524345
hlkhl|245235
.