Extensions and phpBB 3.2: you should probably read this topic

Discussion forum for Extension Writers regarding Extension Development.
rxu
Extensions Development Team
Posts: 3711
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Contact:

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by rxu »

OK, thanks for the explanation.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

i am developer of this extension viewtopic.php?f=456&t=2427126 and i need know more about refractor.

Code: Select all

[quote]test[/quote]

test
code above, one '\n' after quote tag will result without any br tag after blockquote tag. (check image below)
Image

need two '\n' after quote tag to create one br like code below

Code: Select all

[quote]test[/quote]


test
finally one br tag. (check image below)
Image

Is this really normal behavior? Or intentional? Or is it bug?
For me, the correct behavior is a '\ n' will result in a br tag.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

It's intentional. Up to 1 blank line (= 2 line feeds) is ignored after BBCodes that are rendered as block elements.

If you CKEditor doesn't have a similar option, you may want to hide the superfluous <br> in CSS with something like that:

Code: Select all

.ClassNameOfTheEditableElement blockquote+br
{
	display: none;
}
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

JoshyPHP wrote: Sat Jun 17, 2017 12:14 pm It's intentional. Up to 1 blank line (= 2 line feeds) is ignored after BBCodes that are rendered as block elements.

If you CKEditor doesn't have a similar option, you may want to hide the superfluous <br> in CSS with something like that:

Code: Select all

.ClassNameOfTheEditableElement blockquote+br
{
	display: none;
}
thanks for reply. custom bbcode Is treated as an block elements? like align bbcode.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

Anything that is rendered as a block-level element: quotes, code blocks, lists, etc... It doesn't matter whether they are custom or by default, they are all treated the same.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

thanks the explanation. i will try what i can to do here.
doougl4s
Registered User
Posts: 4
Joined: Fri Feb 12, 2016 8:27 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by doougl4s »

Many of my bbcodes have stopped working, can you tell me how to fix this?

Code: Select all

[col]{TEXT1}|{TEXT2}[/col]

<table width="100%">
	<tr>
		<td style="vertical-align: top; width:50%; padding-right:10px;">{TEXT1}</td>
		<td style="vertical-align: top; width:50%; padding-left:10px;">{TEXT2}</td>
	</tr>
</table>

Code: Select all

[tabela]{TEXT}[/tabela]

<script language="Javascript">
var texto = '{TEXT}';
texto = texto.replace("\r\n","");
texto = texto.replace("<br>","");
texto = texto.replace(" ","");
var linha = new Array();
linha = texto.split('L=');
var table = '<div align="center"><TABLE width=70% cellpadding=1 cellspacing=1 border=0>';
for (var i=1; i<linha.length; i++)
{
  table = table + '<TR>';
  var coluna = new Array();
  coluna = linha[i].split('&');
  for (var j=0; j<coluna.length; j++)
  {
    if (i == 1)
    {
      table = table + '<TD align=center style="background: #FF8904; font-size:11px; color:black; font-family:  Verdana,Arial, Helvetica, sans-serif;"><b>' + coluna[j].replace("amp;","") + '</b></TD>';      
    }
    else
    {
      table = table + '<TD style="background: #878282; font-size:11px; color:white; font-family:  Verdana,Arial, Helvetica, sans-serif;">' + coluna[j].replace("amp;","") + '</TD>';      
    }

  }
  table = table + '<TR>';
}
table = table + '</TABLE></div>';
document.write(table);
</script>

Code: Select all

[thumbnail={NUMBER}]{URL}[/thumbnail]

<a target="_blank" href="{URL}"><img src="{URL}" width="{NUMBER}px" heigth="{NUMBER}px"></a>
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

This topic is for extension authors, not for general support. Please use the general support forums for that.

Off the top of my head, the first BBCode will work differently in 3.2 because of the multiple tokens in the BBCode's content. If you use more than one token in the BBCode's content, the content will be treated as plain text. The second BBCode I don't know about. Using JavaScript seems like a bad idea. Some browsers have deprecated/removed support for document.write too. The last one I don't know either. My guess is it works.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

@JoshyPHP

Why need three '\n' after block element to create one br if next tag too is block element?

Need two '\n' after block element to create one br if next tag is inline element. This ok, but why three '\n' between blocks elements to one br?
This too intentional?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

Up to two newlines are ignored after block elements so that you can use the following markup without extra <br> elements appearing in the output:

Code: Select all

[quote=martec post_id=14779661 time=1499942629 user_id=1100965]
Why need three '\n' after block element to create one br if next tag too is block element?
[/quote]

Reply goes here, no br.
Without extra <br> elements, users can leave a blank space between markup for readability without adding superfluous whitespace in the output and style authors margins can better control margins in CSS without having to account for extra <br>s.

Note that you can toggle that behaviour in custom BBCodes in their definition:

Code: Select all

[foo #ignoreSurroundingWhitespace=false]{TEXT}[/foo]
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

@JoshyPHP

That was not quite what I meant.

Code: Select all

[quote]test[/quote]



[quote]test[/quote]
Code above block element (first quote tag) and next element (secound quote tag) also block element. To create one br need three '\n'. Why? Intentional?

If something below

Code: Select all

[quote]test[/quote]


test
Code above block element and next element is inline element. Here need only two '\n' to create one br. Why this difference?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

Up to two newlines are ignored before and after block elements. They might add up depending on the context, which is why you need three of them when there are two consecutive blocks.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

@JoshyPHP

Hi, Is there an event in phpBB where I can change the number of lines that will be ignored before and after blocks elements?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

Not the number, no.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

So you have your parser for javascript?
Post Reply

Return to “Extension Writers Discussion”