[RFC] Integrate s9e\TextFormatter

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.2/Rhea branch. Everything listed in this forum will be available in phpBB 3.2.
Post Reply
CHItA
Development Team
Development Team
Posts: 128
Joined: Thu Mar 12, 2015 1:43 pm
Location: Budapest, Hungary

Re: [RFC] Integrate s9e\TextFormatter

Post by CHItA » Sun Nov 06, 2016 10:37 am

xiri wrote:
Sun Nov 06, 2016 10:29 am
Why 3.2 version of parsing is better?
Thanks in advance!
That is just the format that the TextFormatter uses. How one stores data is not really makes anything better or worse, the reason why 3.2's BBCode parsing is better is just simply because the features that comes from the new TextFormatter.

xiri
Registered User
Posts: 3
Joined: Sun Nov 06, 2016 10:27 am

Re: [RFC] Integrate s9e\TextFormatter

Post by xiri » Sun Nov 06, 2016 10:48 am

CHItA wrote:
Sun Nov 06, 2016 10:37 am

That is just the format that the TextFormatter uses. How one stores data is not really makes anything better or worse, the reason why 3.2's BBCode parsing is better is just simply because the features that comes from the new TextFormatter.
Can I use the old parsing format in some way? Maybe there are some settings?

User avatar
JoshyPHP
Registered User
Posts: 350
Joined: Fri Jul 08, 2011 9:43 pm

Re: [RFC] Integrate s9e\TextFormatter

Post by JoshyPHP » Sun Nov 06, 2016 12:28 pm

No, there's no such setting. Why do you need the old format?

xiri
Registered User
Posts: 3
Joined: Sun Nov 06, 2016 10:27 am

Re: [RFC] Integrate s9e\TextFormatter

Post by xiri » Sun Nov 06, 2016 5:17 pm

JoshyPHP wrote:
Sun Nov 06, 2016 12:28 pm
No, there's no such setting. Why do you need the old format?
Thanks for the answer! I am planning to add a forum to a mobile application and will make api. I would like to work with a more familiar format. Now I am considering 3.1 and 3.2 to determine what is best version to use for my purposes.

User avatar
3Di
Registered User
Posts: 695
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano (I) Frankfurt (D)
Contact:

Re: [RFC] Integrate s9e\TextFormatter

Post by 3Di » Mon Nov 07, 2016 5:22 am

xiri wrote:
Sun Nov 06, 2016 5:17 pm
JoshyPHP wrote:
Sun Nov 06, 2016 12:28 pm
No, there's no such setting. Why do you need the old format?
Thanks for the answer! I am planning to add a forum to a mobile application and will make api. I would like to work with a more familiar format. Now I am considering 3.1 and 3.2 to determine what is best version to use for my purposes.
This ticket? https://tracker.phpbb.com/browse/PHPBB3-13802
I think is a great idea. Any news?
Want to compensate me for my interest? Don't ask me, just do it
I'm available for custom phpBB jobs, you can PM me the details.
New: my Live Board, Extensions and Tools for phpBB - Men at works.

User avatar
rxu
Registered User
Posts: 124
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: [RFC] Integrate s9e\TextFormatter

Post by rxu » Sun Jan 22, 2017 6:37 am

Having 2 bbcodes - one without and another with the = sign, like that:
[ref]{TEXT}[/ref]
<span style="font-weight: bold;">{TEXT}</span>


[ref={COLOR}]{TEXT}[/ref]

<span style="font-weight: bold; color: {COLOR};">{TEXT}</span>

And the former isn't parsed but the latter is.
Is that intended or a bug?
Image

User avatar
JoshyPHP
Registered User
Posts: 350
Joined: Fri Jul 08, 2011 9:43 pm

Re: [RFC] Integrate s9e\TextFormatter

Post by JoshyPHP » Sun Jan 22, 2017 1:14 pm

Kind of neither. I discovered that phpBB would allow two custom BBCodes of the same name if exactly one of them used a parameter a good 2 years after finishing the implementation. Since then I haven't really seen any real-world example of such a pair of BBCodes. There's a ticket there: https://tracker.phpbb.com/browse/PHPBB3-14357

I wrote a routine to merge those BBCode definitions during loading but I didn't have any real-world data to test it against so it never went anywhere: https://gist.github.com/JoshyPHP/6d9c2f ... d854dcc542

Maybe this could be implemented as a migration so that the new definition appears in the ACP (replacing the two old definitions) instead of being implicitly merged. Would you be interested in taking point on this?

User avatar
rxu
Registered User
Posts: 124
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: [RFC] Integrate s9e\TextFormatter

Post by rxu » Sun Jan 22, 2017 1:53 pm

I would, although I have no clue where I could be useful (excepting real bbcode definitions and/or testing).
Image

User avatar
JoshyPHP
Registered User
Posts: 350
Joined: Fri Jul 08, 2011 9:43 pm

Re: [RFC] Integrate s9e\TextFormatter

Post by JoshyPHP » Sun Jan 22, 2017 5:55 pm

You can be useful by handling the PR from start to finish. The best way to handle multiple BBCode definitions with the same name may be to replace them with a definition that covers both use case, and do so as a migration.

So far I've seen two different use cases:
  1. The [url] BBCode requires a value for the URL but if the user doesn't give one it uses the content of the BBCode. Either way the template is the same.
  2. Your [ref] BBCode accepts an optional parameter and uses a different template whether it is present or not.
In the first case, the original 3.1 BBCodes are something like that:

Code: Select all

[url]{URL}[/url]

Code: Select all

[url={URL}]{TEXT}[/url]

Code: Select all

<a href="{URL}">{TEXT}</a>
The template for 3.2 wouldn't change but the definitions would need to be merged together as such:

Code: Select all

[url={URL;useContent}]{TEXT}[/url]
As I recall, that's what I implemented in the Gist I posted above.

In the second case, both the definitions and templates would need to be merged into something like this:

Code: Select all

[ref={COLOR;optional}]{TEXT}[/ref]

Code: Select all

<xsl:choose>
	<xsl:when test="@*">
		<span style="font-weight: bold; color: {COLOR};">{TEXT}</span>
	</xsl:when>
	<xsl:otherwise>
		<span style="font-weight: bold;">{TEXT}</span>
	</xsl:otherwise>
</xsl:choose>
In the template above, @* is an XPath expression that means "all/any attributes."
Last edited by JoshyPHP on Fri Jan 27, 2017 2:57 am, edited 1 time in total.

User avatar
Ger
Registered User
Posts: 270
Joined: Mon Jul 26, 2010 1:55 pm
Location: 192.168.1.100
Contact:

Re: [RFC] Integrate s9e\TextFormatter

Post by Ger » Tue Jan 24, 2017 11:04 am

I see the optional attribute actually works if I put this in the ACP:
[ref={COLOR;optional;defaultValue=inherit}]{TEXT}[/ref]
It accepts both ways, eg. when I write this:

Code: Select all

[ref]Test without attr[/ref]
plain text
[ref=#FF0000]Test with red color[/ref]
It gets parsed like

Code: Select all

<span style="font-weight: bold; color: inherit;">Test without attr</span><br>
plain text<br>
<span style="font-weight: bold; color: #FF0000;">Test with red color</span><br>
Hence: if no color is given, it uses the default value (in this case: inherit). Of course some conditional statements like de XSL scheme would be more powerful, but I think this would cover most cases where an optional attribute is required.
Above message may contain errors in grammar, spelling or wrongly chosen words. This is because I'm not a native speaker. My apologies in advance.

Post Reply