Custom BB Code basics

Get help developing custom BBCodes or request one.
Post Reply
thom_forum
Registered User
Posts: 19
Joined: Thu Aug 09, 2018 2:06 pm

Custom BB Code basics

Post by thom_forum »

Good afternoon everyone,

I set up phpBB3.2 recently, to see if it would be usable for our purposes. So far it's looking good, but there's a few things I can't get done right (entirely my fault, I assume).

I'm trying to set up ways for people to post code from another forum (using it's own brand of BB code) by simply copy&paste, and it's supposed to get rendered correctly in the phpBB forum. Most of this is really straightforward and easily done as custom BB Code. But I'm missing some basics, so some of the things I can't work out yet.
Ok, get to the point.

This is a Minimum Working Example of code as it would come from the other forum:

Code: Select all

[table][tr][th colspan=3 align=center]Lineup Undefined[/th][/tr]
[tr][td]1[/td][td]2[/td][td]3[/td][/tr]
[/table]
This would create a table with the head spanned over 3 columns. I can't work out for the life of me how to tell phpBB to convert that propperly.
I'm currently trying

Code: Select all

[th {TEXT1?} {TEXT2?}]{TEXT3}[/th]
converting to

Code: Select all

<td {TEXT1} {TEXT2} style="text-align:left;font-weight:bold;background-color:#c0c0c0;border: 1px solid black;padding: 8px;">{TEXT}</th>


I read about using {TEXT1?} in case some token isn't required, which is the case here - the colspan (or the align=center) could be omitted.

Like I said (and the above ham-fisted coding proves) I'm really fumbling through this blindly and needs some pointers.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53412
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Custom BB Code basics

Post by Brf »

Moved to Custom BBCode forum...

Have a look at some of the topics further down this forum. Joshyphp is your expert. A "space" is a valid character within a TEXT tag, so separating TEXT tags with a space (or just about any other character) will not work.
thom_forum
Registered User
Posts: 19
Joined: Thu Aug 09, 2018 2:06 pm

Re: Custom BB Code basics

Post by thom_forum »

Thanks for the move.
Right, the token definition actually mentions that. So, I SHOULD be able to work with just one TEXT-token, right? Here's my latest, failed attempt:

BBCode:

Code: Select all

[th{TEXT1?}]{TEXT2}[/th]
HTML Replacement:

Code: Select all

<td {TEXT1} style="text-align:left;font-weight:bold;background-color:#c0c0c0;border: 1px solid black;padding: 8px;">{TEXT2}</th>
Notice I cleaned up an error in the last token, where I had only used {TEXT} in the replacement initially. Still, no dice.

Is this "add ? to make the token optional" an actual thing? Or was that blog post I came across valid? Is there some deeped documentation on Custom BBCode somewhere? I really looked, but can't find much worthwhile.
thom_forum
Registered User
Posts: 19
Joined: Thu Aug 09, 2018 2:06 pm

Re: Custom BB Code basics

Post by thom_forum »

Ok, so this is driving me insane. All I want is to build a BBCode that recognizes builds a table, where td and th can possibly contain attributes like colspan, but doesn't have to.

I still think

Code: Select all

[td {TEXT1?}]{TEXT2}[/td]
should work, but I'm beginning to think phpBB doesn't follow through with this because of the XSS security threat. Not sure. Any other reason why that wouldn't work? Does the '?' actual mean "Token is optional" like I found on one website (that I can't find again) or is there another way to have optional tokens?
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26546
Joined: Fri Aug 29, 2008 9:49 am

Re: Custom BB Code basics

Post by Mick »

The [RC] Tables extension may do what you want.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
thom_forum
Registered User
Posts: 19
Joined: Thu Aug 09, 2018 2:06 pm

Re: Custom BB Code basics

Post by thom_forum »

Thanks for that, but that won't do (I have already looked at that).
Reason I'm doing this is: We going to be copying text over from another forum and I'm working to have that render correctly, without anyone having to adjust anything or manually add tags and such.

I've got it working, except for where the source has [td] tags with attributes. They still render, but the attributes get ignored, which means colspan doesn't work => tables look weird.
Post Reply

Return to “Custom BBCode Development and Requests”