New left, right and center-aligned table bbCodes. New escape bbCode.

Post Reply
User avatar
Dave Keenan
Site Admin
Posts: 1564
Joined: Tue Sep 01, 2015 2:59 pm
Location: Brisbane, Queensland, Australia

New left, right and center-aligned table bbCodes. New escape bbCode.

Post by Dave Keenan »

In addition to the basic table bbCodes: [table], [tr], [th], [td], Douglas and I have added the following table bbCodes to allow both headings and data to be aligned left, right or center:

heading[thl][thc] or [th][thr]
data[tdl] or [td][tdc][tdr]

Please ignore any previous announcement you may have seen about tn or tc. They no longer exist.

We also defined a new bbCode [_] for escaping other bbCodes, i.e. for preventing them from being interpreted, so that we can talk about them in forum posts. The bbCode [_] merely generates a left square bracket [. For example, to talk about the bold bbCode [b] you would write [_]b]. i.e. you would insert _] (i.e. underscore, right bracket) after the opening square bracket of the bbCode whose interpretation you want to prevent.

The above table makes use of all these new bbCodes. Here is the code that generated it (with the content shown in red):

[tr][thl]heading[/thl][tdl][_]thl][/tdl][tdc][_]thc] or [_]th][/tdc][tdr][_]thr][/tdr][/tr]
[tr][thl]data[/thl][tdl][_]tdl] or [_]td][/tdl][tdc][_]tdc][/tdc][tdr][_]tdr][/tdr][/tr]

User avatar
Site Admin
Posts: 1240
Joined: Tue Feb 11, 2020 3:10 pm
Location: San Francisco, California, USA
Real Name: Douglas Blumeyer

Re: New left, right and center-aligned table bbCodes. New escape bbCode.

Post by cmloegcmluin »

And if you want to get really fancy, we've also added the ability to merge cells horizontally. You may need this feature, for example, if you want to have separate columns for the terms of your quotients and your monzos, while still having one centered cell which spans across them holding the main column title:

symbolnamen/d  2 3 5 7 cents
:/|\:11M33/32[ 0 0 1 45.450¢
25/49M50/49[ 1 0 2 -2 33.400¢

The way to use this feature is simple. For any table cell bbCode ([th], [td], [thl], [thc], [thr], [tdl], [tdc], [tdr]), inside the brackets, add an equals sign followed by the number of columns to span, like this: [th=6]. It is important, though, that you then delete n-1 cells just to the right of the cell to which you are adding a span, to counteract its new span.

Here's an example:

      1           2        3        4        5        6          7


   1 2 3 4 5 6         7
[th=6]monzo[/th] [th]cents[/th]

So, I set my column span to 6, and then deleted the 6 - 1 = 5 cells just to the right. Those five cells have essentially been merged with this "monzo" cell.

We do not yet support vertical merging. If anyone needs it, let me know.

Post Reply