Page MenuHomePhabricator

Allow html attribute on SyntaxHighlight GeSHi extension
Closed, ResolvedPublic

Description

Author: stanley

Description:
Please allow <source> tag to be stylized using HTML attributes


Version: unspecified
Severity: enhancement

Details

Reference
bz10081

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:52 PM
bzimport set Reference to bz10081.

This would be pretty easy; see the Poem extension for an example of how to do this.

sexyeuroboy wrote:

Any traction on this? Reasonably simple request for a simple gain.

  • Chris

Created attachment 7751
allow params for source-tags

I have create a patch, but I am not sure, if that the best way. Feel free to modify or create a new one.

Attached:

a.d.bergi wrote:

Nice, I just tested it at translatewiki.
Was it intended that the textalign an direction can be "overwritten"? textalign would be OK, but dir="rtl" results in dir="ltr rtl" which causes funny behavior at rtl-wikis.

Hmm.

The dir=ltr is only set in one case. Is it worth just checking if it's not been set, and then only conditionally set it?

a.d.bergi wrote:

Are there any sources that can be rtl? I can't think of any programming languages, but theres still lang="text".
I think we can ignore that cases (we already did it in the past), so either

if( isset( $attribs[$name] && $name != 'dir') ) {

or better

$attribs['dir'] = 'ltr';

could be changed. The other way, allowing a custom direction, could be provided by

$attribs['dir'] = $attribs['dir'] || 'ltr';

(Ive got no SVN, sorry)

Sorry, that's a bit hard to follow. Can you just write out the full code block?

a.d.bergi wrote:

if ( $enclose === GESHI_HEADER_NONE ) {
$attribs = self::addAttribute( $attribs, 'class', 'mw-geshi ' . $lang . ' source-' . $lang );
} else {

  • $attribs = self::addAttribute( $attribs, 'dir', 'ltr' );

+ $attribs['dir'] = $attribs['dir'] || 'ltr';

	$attribs = self::addAttribute( $attribs, 'class', 'mw-geshi' );

$attribs = self::addAttribute( $attribs, 'style', 'text-align: left;' );
}

Im not sure whether PHP handles this automatic typecasting right, a more detailed version would be
+ if ( is_null($attribs['dir']) ) $attribs['dir'] = 'ltr';

if ( !isset( $attribs['dir'] ) ) {
$attribs['dir'] = 'ltr';
}

I suppose...