Skip to content

Commit

Permalink
Enable class attribute to add CSS classes
Browse files Browse the repository at this point in the history
  • Loading branch information
akzhan committed Mar 13, 2012
1 parent 89b4b3d commit 596c482
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion GoogleCodePrettify.body.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

class GoogleCodePrettify {
private static $prettified = false;

public static function parserHook($text, $args = array(), $parser) {
$pre_classes = '';
if (isset($args['lang']) && $args['lang']) {
$lang = $args['lang'];
$pre_classes .= " lang-$lang";
}
if (isset($args['class']) && $args['class']) {
$pre_classes .= ' '. $args['class'];
}
self::$prettified = true;

return "<pre class=\"prettyprint$pre_classes\">$text</pre>";
Expand Down
2 changes: 1 addition & 1 deletion GoogleCodePrettify.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function efGoogleCodePrettify_Setup( &$parser ) {
'name' => 'GoogleCodePrettify',
'author' => 'Akzhan Abdulin',
'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleCodePrettify',
'version' => '0.1',
'version' => '0.2',
'descriptionmsg' => 'google-code-prettify-description'
);

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ That's all.

Google Code Prettify automatically recognizes language of source code. But you can set it using *lang* attribute.

## class attribute

You can add additional CSS class names to generated **pre** tags using *class* attribute. This is useful, for example, to add *mw-collapsible* class.

## Configuration

### Enable handling of **source** tag.
Expand Down

0 comments on commit 596c482

Please sign in to comment.