function mathjax_page_alter in MathJax: LaTeX for Drupal 7.2
Implements hook_page_alter().
File
- ./
mathjax.module, line 87 - MathJax module.
Code
function mathjax_page_alter(&$page) {
$module_path = drupal_get_path('module', 'mathjax');
if (variable_get('mathjax_config_type', 0) == 0) {
$config_string = mathjax_default('config string');
}
else {
$config_string = variable_get('mathjax_config_string', mathjax_default('config string'));
}
// Load Mathjax.
$config = array(
'#type' => 'markup',
'#markup' => '<script type="text/x-mathjax-config">' . $config_string . '</script>',
);
$page['content']['#attached']['drupal_add_html_head'] = array(
array(
$config,
'mathjax-config',
),
);
$page['content']['#attached']['js'][$module_path . '/mathjax.js'] = array(
'every_page' => TRUE,
);
if (variable_get('mathjax_use_cdn', TRUE)) {
$cdn_url = variable_get('mathjax_cdn_url', mathjax_default('cdn url'));
$page['content']['#attached']['js'][$cdn_url] = array(
'type' => 'external',
);
}
else {
if (function_exists('libraries_get_path')) {
$library_path = libraries_get_path('mathjax', TRUE) . '/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
$page['content']['#attached']['js'][$library_path] = array(
'type' => 'external',
);
}
}
}