Skip to content

Commit

Permalink
Add the CSS class math-wrapper to the <dmath> and <math> tags
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg committed Jan 24, 2016
1 parent 44d022e commit 5820d74
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion DMathHooks.php
Expand Up @@ -13,6 +13,7 @@ function onParserFirstCallSetup(Parser $parser) {
}

$parser->setHook('dmath', 'DMathParse::dmathTagHook' );
$parser->setHook('math', 'DMathParse::mathTagHook' );

}

Expand All @@ -23,8 +24,24 @@ function dmathTagHook( $content, $attributes, $parser ) {
$tag = $attributes['type'];
$content = ' \\begin{'.$tag.'} '.$content.'\\end{'.$tag.'}';
}
return MathHooks::mathTagHook($content, $attributes, $parser);
$text = MathHooks::mathTagHook( $content, $attributes, $parser );

$text[0] = Html::rawElement ('div', array( 'class' => 'math-wrapper' ), $text[0] );

return $text;
}

function mathTagHook( $content, $attributes, $parser ) {

$text = MathHooks::mathTagHook($content, $attributes, $parser);

// the MathHooks::mathTagHooks function returns a array with some attributes, but we only want to change the text, which is at [0].
$text[0] = Html::rawElement( 'span', array( 'class' => 'math-wrapper' ), $text[0] );

return $text;

}

}

?>

0 comments on commit 5820d74

Please sign in to comment.