Skip to main content
Bbc integration issues Started by Frenzie · · Read 9945 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic - Topic derived from ElkArte 1.1 Final - Release a...

Bbc integration issues

Did something change about integrate_bbc_codes? I'm doing some pre-upgrade checks and most things seem to be working alright, but not Headers BBC or these BBCs from SMF:

Code: [Select]
	public static function bbc_codes(&$codes, &$no_autolink_tags, &$itemcodes)
{
$codes[] = array(
'tag' => 'glow',
'type' => 'unparsed_commas',
'test' => '[#0-9a-zA-Z\-]',
'before' => '<span style="text-shadow: $1 0 0 4px">',
'after' => '</span>',
);
$codes[] = array(
'tag' => 'shadow',
'type' => 'unparsed_commas',
'test' => '[#0-9a-zA-Z\-]{3,12},(left|right|top|bottom|[0123]\d{0,2})\]',
'before' => '<span style="text-shadow: $1 $2">',
'after' => '</span>',
'validate' => create_function('&$tag, &$data, $disabled', '
if ($data[1] == \'top\' || (is_numeric($data[1]) && $data[1] < 50))
$data[1] = \'0 -2px 1px\';
elseif ($data[1] == \'right\' || (is_numeric($data[1]) && $data[1] < 100))
$data[1] = \'2px 0 1px\';
elseif ($data[1] == \'bottom\' || (is_numeric($data[1]) && $data[1] < 190))
$data[1] = \'0 2px 1px\';
elseif ($data[1] == \'left\' || (is_numeric($data[1]) && $data[1] < 280))
$data[1] = \'-2px 0 1px\';
else
$data[1] = \'1px 1px 1px\';'),
);
}
The forum has a nice green checkmark next to integrate_bbc_codes, but it's not actually doing anything.

Re: Bbc integration issues

Reply #1

@Frenzie bbcode in 1.1 changed
You can see how I updated the example ~ link ~
Sorry for my English

Re: Bbc integration issues

Reply #2

@inter Thanks!
Last Edit: November 04, 2017, 04:49:35 pm by Frenzie

Re: Bbc integration issues

Reply #3

Okay, whose idea was it to name that hook bbc_codes_parsing instead of integrate_bbc_codes_parsing.  >:(  :'(

Quote from: Some semi-random debug outputintegrate_additional_bbc, integrate_autolink_load, integrate_news_html_parser, integrate_html_parser_load, integrate_news_bbc_parser, integrate_item_codes, bbc_codes_parsing

Edit:
@emanuele Could you maybe give me a hint regarding what I'm missing? It's not working.

Code: [Select]
	public static function bbc_codes_parsing(&$codes, &$itemcodes)
{
$codes[] = array(
BBC\Codes::ATTR_TAG => 'glow',
BBC\Codes::ATTR_TYPE => BBC\Codes::TYPE_UNPARSED_COMMAS,
BBC\Codes::ATTR_TEST => '[#0-9a-zA-Z\-]',
BBC\Codes::ATTR_BEFORE => '<span style="text-shadow: $1 0 0 4px">',
BBC\Codes::ATTR_AFTER => '</span>',
BBC\Codes::ATTR_QUOTED => BBC\Codes::OPTIONAL,
BBC\Codes::ATTR_BLOCK_LEVEL => false,
BBC\Codes::ATTR_AUTOLINK => true,
BBC\Codes::ATTR_LENGTH => 4,
);
$codes[] = array(
BBC\Codes::ATTR_TAG => 'shadow',
BBC\Codes::ATTR_TYPE => BBC\Codes::TYPE_UNPARSED_COMMAS,
BBC\Codes::ATTR_TEST => '[#0-9a-zA-Z\-]{3,12},(left|right|top|bottom|[0123]\d{0,2})\]',
BBC\Codes::ATTR_BEFORE => '<span style="text-shadow: $1 $2">',
BBC\Codes::ATTR_AFTER => '</span>',
BBC\Codes::ATTR_VALIDATE => function(&$tag, &$data, $disabled) {
if ($data[0] == 'top' || (is_numeric($data[1]) && $data[1] < 50))
$data[1] = '0 -2px 1px';
elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100))
$data[1] = '2px 0 1px';
elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190))
$data[1] = '0 2px 1px';
elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280))
$data[1] = '-2px 0 1px';
else
$data[1] = '1px 1px 1px';},
BBC\Codes::ATTR_QUOTED => BBC\Codes::OPTIONAL,
BBC\Codes::ATTR_BLOCK_LEVEL => false,
BBC\Codes::ATTR_AUTOLINK => true,
BBC\Codes::ATTR_LENGTH => 6,
);
// test; working
$codes[] = array(
BBC\Codes::ATTR_TAG => 'j',
BBC\Codes::ATTR_TYPE => BBC\Codes::TYPE_PARSED_CONTENT,
BBC\Codes::ATTR_BEFORE => '<strong class="bbc_strong">',
BBC\Codes::ATTR_AFTER => '</strong>',
BBC\Codes::ATTR_BLOCK_LEVEL => false,
BBC\Codes::ATTR_AUTOLINK => true,
BBC\Codes::ATTR_LENGTH => 1,
);
}
Last Edit: November 04, 2017, 04:42:10 pm by Frenzie

Re: Bbc integration issues

Reply #4

Thanks for raising bbc issue. Reminds me of finishing mine too.

Re: Bbc integration issues

Reply #5

Was trying to fix one that i was using in rssfeedposter html bbc

Re: Bbc integration issues

Reply #6

When I reach a proper computer I'll check it better.
The naming is likely a refactoring overlook...

 emanuele takes note to create a test for hooks naming convention
Bugs creator.
Features destroyer.
Template killer.

Re: Bbc integration issues

Reply #7

I suppose the lack of integrate_ is technically a bug report but otherwise it may just be a support question. Unless BBC\Codes::TYPE_UNPARSED_COMMAS is broken. ;)

Re: Bbc integration issues

Reply #8

You should try integrate_additional_bbc to add new codes to the system, not the item codes hook.

Re: Bbc integration issues

Reply #9

Quote from: vbgamer45 – Was trying to fix one that i was using in rssfeedposter html bbc
You may need to wait for 1.1.1 for help in protecting code blocks via integrate_preparse_code. 

Preparse was also redone and no longer loops on the preg_split but instead replaces code blocks with tokenized holders.  As such integrate_preparse_code, specifically the old $i value has no real meaning, its always 0 but has all of the code in the data string.  Its not the old 0 is above the code .... 

In 1.1.1 I added an integrate_preparse_tokenized_code hook, that one will have the code blocks safe from processing so you can take that data and safely work on it w/o affecting whats inside the code blocks.

Re: Bbc integration issues

Reply #10

Quote from: Spuds – You should try integrate_additional_bbc to add new codes to the system, not the item codes hook.
Will do, but note that the test at the bottom works so even without having tried it I doubt that'd make a different wrt what I'm missing.

Edit: @Spuds Unfortunately as expected no change.
Last Edit: November 05, 2017, 04:14:38 pm by Frenzie

Re: Bbc integration issues

Reply #11

Before I call this a bug .... Looking at your code,

1) glow ... I'm not sure why you chose TYPE_UNPARSED_COMMAS since it looks like you just want to extract a color name or color code and use that.   I'd first try by changing the type and then make sure you capture the entire thing, right now the test is only going to pass (and return) a single character, so that needs to expand (done dirty below)
Code: [Select]
				self::ATTR_TYPE => self::TYPE_UNPARSED_EQUALS,
self::ATTR_TEST => '[#0-9a-zA-Z\-]*?',

2) shadow ... this looks fine except for the test, you don't need or want to add that trailing \] in the test as the system does that for you now.
Code: [Select]
			self::ATTR_TEST => '[#0-9a-zA-Z\-]{3,12},(left|right|top|bottom|[0123]\d{0,2})',

Re: Bbc integration issues

Reply #12

Quote from: Spuds – 1) glow ... I'm not sure why you chose TYPE_UNPARSED_COMMAS since it looks like you just want to extract a color name or color code and use that.   I'd first try by changing the type and then make sure you capture the entire thing, right now the test is only going to pass (and return) a single character, so that needs to expand (done dirty below)
Code: [Select]
				self::ATTR_TYPE => self::TYPE_UNPARSED_EQUALS,
self::ATTR_TEST => '[#0-9a-zA-Z\-]*?',

This is SMF code that was removed from Elk for some reason.[1] I didn't choose anything other than to copy/paste it into an extension. :P

What I want is for it to remain perfectly compatible, and the surest way to do so is not to change it at all.

Anyway, real life glow usage looks like this:

Code: [Select]
[glow=green,2,300]I'm green.[/glow]

Looks a lot like commas to me. ;)
By certain unnamed parties.

Re: Bbc integration issues

Reply #13

I see what you're getting at though.

SMF docs: https://wiki.simplemachines.org/smf/Glow

Basically the full glow was always an IE-only thing https://github.com/elkarte/Elkarte/commit/075c90c06d76f63e5458021c829b153ca8e7d992

In any case, it should properly eat comma values even if it might be temporarily unsupported in the output.  ;D

Re: Bbc integration issues

Reply #14

At that point in Elk it appears we had already dropped the IE glow support, so the code was just glow=blue or whatever.  Never documented or probably tested since it was removed then.  The old SMF code is
Code: [Select]
			array(
'tag' => 'glow',
'type' => 'unparsed_commas',
'test' => '[#0-9a-zA-Z\-]{3,12},([012]\d{1,2}|\d{1,2})(,[^]]+)?\]',
'before' => $context['browser']['is_ie'] ? '<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Glow(color=$1, strength=$2); font: inherit;">' : '<span style="text-shadow: $1 1px 1px 1px">',
'after' => $context['browser']['is_ie'] ? '</td></tr></table> ' : '</span>',
),

If you want to support the old glow codes, I'd update the test to
Code: [Select]
 '[#0-9a-zA-Z\-]{3,12},([012]\d{1,2}|\d{1,2})(,[^]]+)?
  That will parse the commas but not use them at all as only the first capture (the color name $1) will be used in the span ... in theory.