Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • 29.x protected
  • 24.x protected
  • 27.x protected
  • 28.x protected
  • 26.x protected
  • tiki-28x-upd_sabredav
  • cherry-pick-516fef7d
  • cherry-pick-64daf51d
  • cherry-pick-56267f6d
  • revert-430ec89f
  • cherry-pick-d6849b89
  • cherry-pick-e1be3e6e
  • cherry-pick-7d3783ff
  • cherry-pick-4ab19f63
  • revert-ccc3532b
  • 21.x protected
  • cherry-pick-04c96162
  • cherry-pick-f3f36c1a
  • cherry-pick-78c104d5
  • tags/29.0alpha
  • tags/24.9
  • tags/27.3
  • tags/28.4
  • tags/21.12
  • tags/24.8
  • tags/27.2
  • tags/28.3
  • tags/28.2
  • tags/28.1
  • tags/28.0
  • tags/21.11
  • tags/28.0RC1
  • tags/21.10
  • tags/28.0beta
  • tags/24.7
  • tags/26.3
  • tags/27.1
  • tags/28.0alpha
  • tags/27.0
40 results

wikiplugin_equation.php

Blame
  • Josaphat Imani's avatar
    Josaphat Imani authored and Benoit Grégoire committed
    29f0a80a
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    wikiplugin_equation.php 1.33 KiB
    <?php
    
    // (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
    //
    // All Rights Reserved. See copyright.txt for details and a complete list of authors.
    // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
    use Tiki\Package\VendorHelper;
    
    function wikiplugin_equation_info()
    {
        return [
            'name' => tra('Equation'),
            'documentation' => 'PluginEquation',
            'description' => tra('Render an equation written in LaTeX syntax as an image'),
            'prefs' => ['wikiplugin_equation'],
            'body' => tra('equation'),
            'iconname' => 'superscript',
            'introduced' => 2,
            'packages_required' => ['mathjax/mathjax' => VendorHelper::getAvailableVendorPath('mathjax', 'mathjax/mathjax/MathJax.js')],
        ];
    }
    
    function wikiplugin_equation($data)
    {
        $mathJaxJsFile = VendorHelper::getAvailableVendorPath('mathjax', 'mathjax/mathjax/MathJax.js');
    
        if (! $mathJaxJsFile) {
            Feedback::error(tr('To view equations Tiki needs the mathjax/mathjax package. If you do not have permission to install this package, ask the site administrator.'));
            return;
        }
    
        if (empty($data)) {
            return '';
        }
    
        $headerlib = TikiLib::lib('header');
        $headerlib->add_jsfile($mathJaxJsFile . '?config=TeX-AMS-MML_HTMLorMML', true);
    
        return '~np~' . $data . '~/np~';
    }