Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php |
— | — | @@ -89,15 +89,35 @@ |
90 | 90 | $out = str_replace( "\n", '', $out ); |
91 | 91 | // Register CSS |
92 | 92 | $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" ); |
| 93 | + |
| 94 | + $encloseTag = $enclose === GESHI_HEADER_NONE ? 'span' : 'div'; |
| 95 | + $attribs = Sanitizer::validateTagAttributes( $args, $encloseTag ); |
| 96 | + |
| 97 | + //lang is valid in HTML context, but also used on GeSHi |
| 98 | + unset( $attribs['lang'] ); |
| 99 | + |
93 | 100 | if ( $enclose === GESHI_HEADER_NONE ) { |
94 | | - $out = '<span class="mw-geshi '.$lang.' source-'.$lang.'">' . $out . '</span>'; |
| 101 | + $attribs = self::addAttribute( $attribs, 'class', 'mw-geshi ' . $lang . ' source-' . $lang ); |
95 | 102 | } else { |
96 | | - $out = '<div dir="ltr" class="mw-geshi" style="text-align: left;">' . $out . '</div>'; |
| 103 | + $attribs = self::addAttribute( $attribs, 'dir', 'ltr' ); |
| 104 | + $attribs = self::addAttribute( $attribs, 'class', 'mw-geshi' ); |
| 105 | + $attribs = self::addAttribute( $attribs, 'style', 'text-align: left;' ); |
97 | 106 | } |
| 107 | + $out = Xml::tags( $encloseTag, $attribs, $out ); |
| 108 | + |
98 | 109 | wfProfileOut( __METHOD__ ); |
99 | 110 | return $out; |
100 | 111 | } |
101 | 112 | |
| 113 | + private static function addAttribute( $attribs, $name, $value ) { |
| 114 | + if( isset( $attribs[$name] ) ) { |
| 115 | + $attribs[$name] = $value . ' ' . $attribs[$name]; |
| 116 | + } else { |
| 117 | + $attribs[$name] = $value; |
| 118 | + } |
| 119 | + return $attribs; |
| 120 | + } |
| 121 | + |
102 | 122 | /** |
103 | 123 | * Take an input specifying a list of lines to highlight, returning |
104 | 124 | * a raw list of matching line numbers. |