Giter Site home page Giter Site logo

mathjax-latex's Introduction

MathJax-LaTeX

Contributors: philliplord, sjcockell, knowledgeblog, d_swan, paulschreiber, jwenerd Tags: mathematics, math, latex, mathml, mathjax, science, res-comms, scholar, academic Requires at least: 3.0 Tested up to: 6.1.1 Stable tag: 1.3.12 Requires PHP: 7.0.0 License: GPLv2

This plugin enables MathJax (http://www.mathjax.org) functionality for WordPress (http://www.wordpress.org).

Description

MathJax enables enables rendering of embedded LaTeX or MathML in HTML pages. This plugin adds this functionality to WordPress. The MathJax JavaScript is inject on-demand only to those pages which require it. This ensures that MathJax is not loaded for all pages, which will otherwise slow loading down.

The MathJax JavaScript can be delivered from your own server, or you can use the Cloudflare Content Distribution Network (CDN), which is the preferred mechanism as it offers increased speed and stability over hosting the JavaScript and configuring the library yourself.

You may embed latex using a variety of different syntaxes. The shortcode (http://codex.wordpress.org/Shortcode_API) syntax is preferred. So [latex]E=mc^2[/latex] will work out of the box. This also forces loading of MathJax.

Additionally, you can use native MathJax syntax -- $$E=mc^2$$ or \(E=mc^2\). However, if this is the only syntax used, the plugin must be explicitly told to load MathJax for the current page. This can be achieved by adding a [mathjax] shortcode anywhere in the post. For posts with both [latex]x[/latex] and $$x$$ syntaxes this is unnecessary.

You can use wp-latex syntax, $latex E=mc^2$. Parameters can be specified as with wp-latex but will be ignored. This means that MathJax-LaTeX should be a drop-in replacement for wp-latex. Because this conflicts with wp-latex, this behaviour is blocked when wp-latex is present, and must be explicitly enabled in the settings.

You can also specify [nomathjax] -- this will block MathJax on the current page, regardless of other tags.

MathJax-LaTeX is developed on GitHub.

Installation

  1. Unzip the downloaded .zip archive to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress

Changelog

1.3.12

  1. Use version 2.7.9 of MathJax JS
  2. Add code comments to all variables, functions and parameters.

1.3.11

  1. Use version 2.7.5 of MathJax JS

1.3.10

  1. Rename class files, per PHPCS
  2. Gracefully handle null values in filter_br_tags_on_math. Thanks to Yang Liu.

1.3.9

  1. Code style changes, per PHPCS 3.3.0 and WPCS 0.14.1
  2. Use PHP 7 short array syntax

1.3.8

  1. Code style changes, per PHPCS 3.1.1 and WPCS 0.14

1.3.7

  1. Update MathJax to 2.7.2

1.3.6

  1. Update location of MathJax CDN

1.3.5

  1. Add support for MathJax config via filter

1.3.4

  1. PHP code cleanup
  2. Always use https URL for MathJax library
  3. Updated "tested up to" to 4.3

1.3.3

  1. Fixed inconsistent version numbers between readme and php file

1.3.2

  1. Further code clean ups.

1.3.1

  1. Accessibility Improvements for Admin page
  2. VIP Coding Standards
  3. MathML tags enabled in TinyMCE

All code for this release was submitted by users of this plugin! Thanks to Jared Wenerd and Paul Schreiber.

1.3.0

  1. Whitelist MathML tags and attributes.
  2. Sanitization of input and escaping of output.

1.2.1

  1. Bug fix: custom location was not correctly applied.
  2. Bug fix: force load was not correctly applied.

1.2

  1. Admin page was open to attack from third party sites which user was logged in as admin.
  2. The admin page has been isolated and rewritten.
  3. All the options have been renamed, which will, unfortunately mean reconfiguring the plugin. In particular, wp-latex syntax is switched off by default.

1.1

  1. Documentation update
  2. Update test-with documentation for WordPress 3.5.1
  3. Tested against MathJax2.1

1.0

  1. Compatibility with MathJax 1.1. Load a default configuration from the MathJax distribution.
  2. Use the MathJax Content Distribution Network to deliver the javascript library. Offers improved performance and stability.

0.2

  1. MathJax.js can be loaded form a configurable URL. Defaults to $PLUGIN/MathJax/MathJax.js

== Upgrade Notice ==

1.3.1

Accessibility improvements.

1.2.1

Bug fix: Custom location was not correctly applied. Bug fix: Force load was not correctly applied.

1.2

Security update. All users advised to update. Options will require resetting.

1.1

Documentation updates only. Upgrade for existing users is optional.

1.0

The 1.0 release offers compatibility with MathJax 1.1, and enables use of the CDN for javascript delivery. Upgrading is strongly recommended.

Copyright

This plugin is copyright Phillip Lord, Newcastle University and is licensed under GPLv2.

mathjax-latex's People

Contributors

cowardcalf avatar jwenerd avatar paulschreiber avatar phillord-ncl avatar sjcockell avatar spiralofhope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mathjax-latex's Issues

Regarding bug fixes

Hi there!
I see that in inline math text when we type $$\therefore$$. It is not working. Showing error.
Please fix it and this plugin is not updated from last 5 months.
The WordPress site shows "untested version" on the latest version of WP.
Next, question- how to disable the Mathjax menu.
Please update as soon as if possible.

Equation not rendered

Greetings,

I'm trying to use this plugin on WordPress 6.1.1, but I can't get it to work. This is how I typed two equations into the block editor:
MathJax-LaTex

And this is what I see in WordPress' preview:
rendered

My browser is the latest version of Firefox, what am I doing wrong?

Cannot enter ampersand into block

Using the Wordpress code editor, I attempt to enter [latex]a &=& b[/latex] and it gets converted to [latex]a &=& b[/latex] which is incorrect.

How do I get ampersands into the latex block?

MathJax typesetting etc loading messages visible

Hi there, I have been using the MathJax-LaTeX plugin to build my WordPress website after switching from Simple MathJax. After I made the switch, I noticed that I get loading messages flashing up in the bottom left of the web page relating to the loading of MathJax (please see the attached screenshots). These are quite distracting when a page loads, so I would like to know if there is a way to switch these messages off?
Thank you in advance
IMG_5998
IMG_5999
IMG_6001
IMG_6002

Uncaught TypeError

After installing mathjax as a wordpress plugin I get the following error.
And latex is not rendered.
Any idea what to do ?

MathJax.js?config&ver=1.3.10:19 Uncaught TypeError: this.params.config.split is not a function
at Object.Config (MathJax.js?config&ver=1.3.10:19)
at Function.execute (MathJax.js?config&ver=1.3.10:19)
at cb (MathJax.js?config&ver=1.3.10:19)
at Object.Process (MathJax.js?config&ver=1.3.10:19)
at Object.Push (MathJax.js?config&ver=1.3.10:19)
at MathJax.js?config&ver=1.3.10:19
at MathJax.js?config&ver=1.3.10:19

Switching Between Text & Visual Editor Mangles MathML

Test equation:

<math>
<mrow>
  <mrow>
        <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo>
            <mrow>
              <mn>4</mn>
              <mo>&InvisibleTimes;</mo>
              <mi>x</mi>
            </mrow>
    <mo>+</mo>
    <mn>4</mn>
  </mrow>
    <mo>=</mo>
    <mn>0</mn>
</mrow>
</math>

Works fine if there aren't any spaces:

<math><mrow><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mrow><mn>4</mn><mo>&InvisibleTimes;</mo><mi>x</mi></mrow><mo>+</mo><mn>4</mn></mrow><mo>=</mo><mn>0</mn></mrow></math>

Steps to reproduce:

  1. Paste equation into Text Editor
  2. Switch to Visual Editor
  3. Switch back to text Editor

Expected:HTML not mangled
Actual: HTML Mangled

step1

step2

step3

About '$$' and '$'.

inline mode doesn't work like:
$ \sum_1^n $

display mode works.
$$ \sum_1^n $$

Is this a bug?

error activating Mathjax plugin in WordPress

Hello,

I'm new to using Mathjax and I'd like to try it on a wordpress.org webpage.
I downloaded the plugin but it gives me an error when I try to activate it:

Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected T_FUNCTION in /.../wp-content/plugins/mathjax-latex/mathjax-latex.php on line 235

Could somebody help with this please?

Kind Regards

Inline-Display mode

Hi all, would it be possible to implement the differentiated choice between "inline" and "diplay" mode separately for Desktop and Mobile?

not working when the equation is too long or too complicated

I found that MathJax won't work well when the equation is too many "A_{1}^{2}", "\text{1233}" or something like that. For example,

$$\large\sum_{i=1}^n\vec{F}_{\text{ext, i}}=\sum_{i=1}^n$$

This equation won't show LaTeX correctly.

However, if I delete =\sum_{i=1}^n, then everything is fine.

$$\large\sum_{i=1}^n\vec{F}_{\text{ext, i}}$$

I really need your help. I love this plugin so much because it enables me to write a physics blog.
Thank you so much.

You can see this two pictures :

https://imgur.com/Myse5vr

https://imgur.com/a/IxXI7

Rendering in Chrome - incorrect font family in MathJax 2.7.9

We are experiencing issue with Chrome/Edge loading in incorrect font family on macOS Ventura 13.3

Chrome/Edge is loading a different font STIXNonUnicode-Regular while Firefox loads STIXNonUnicode.

This was resolved temporarily by forcing plugin to load 3.2.2 version of MathJax JS from CDN via kblog_mathjax_custom_location option

https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

Example of underbraces and unicode box appearing
latex_2

latex_1

refresh latex rendering after page load (after displaying a latex string from an ajax load)

I asked this question on wp plugin support page, i ask it here too, i dont know if this plugin is still maintained..

I am loading and displaying LaTeX-formatted code with AJAX. This occurs after the page has initialized, so the code is not formatted properly. Is there a JavaScript function or event I can call after displaying my AJAX response to refresh the formatting?

Not working in markdown mode

Hi

I tried to use this in markdown mode, but despite shortcodes, nothing worked except small equations within $.. $. I am trying to insert as below in markdown mode of WP Jetpack.

Now we can easily make beautiful inline math like \(\mathrm{pr}_{\theta}(x) = |\langle x|\psi\rangle|^2\) or display math like

\[ \langle x_{\theta}|n\rangle = \frac{e^{-in\theta}}{\sqrt{2^n n! \sqrt{\pi}}} H_n(x) e^{-x^2/2} \]

with standard \(\latex\) syntax and Markdown

Equation numbering

Hi, thank you for this plugin. Is there any way to enable equation numbering? When using MathJaX, I can add the following to the HTML header to enable equation numbering:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>

Is there any way to do this in Wordpress?

Equation scaling in mobile devices

Hi mathjax,
I'm using mathjax for math equation in my wordpress website. I like this plugin very much.
I have one question about the equation scaling in mobile deveices. You can see in the following image, I have a long equation. In desktop environment, the screen is wide enough for this equation. However, this is not the case for mobile device. For mobile device, wordpress block will change their layout, which include change the words layout and scale the image size down. However, for the equation, it will only consume the whitespace between equation and tag. Beyond that, the equation never scale its size down. My question is, is this behavior related to mathjax-latex? Can I make the equation the change the layout, e.g. from one line to two line, or just scale its size down?
Thank you.
屏幕截图 2022-11-10 094357

Document the `mathjax_config` filter

The ability to configure mathjax and add things to it is hampered by the lack of a filter. But the filter does exist, it just isn't mentioned or documented anywhere.

Putting a simple example of using mathjax_config to add a key should eliminate the majority of this plugins support burden

rename readme.txt to readme.markdown

The readme.txt file will be rendered correctly on github if it is renamed to readme.markdown or readme.md. Also, various text editors will see the extension and syntax highlight it.

Failed to Load: /extensions/MathZoom.js

When I load a page containing mathjax code, I see the following error at the bottom.

Failed to Load: /extensions/MathZoom.js

The Mathjax code fails to load the equations.

What I expected: I expected the page to load and display the equations.
What happened instead: The page displays the raw Mathjax code instead.

Enabling single dollar sign for inline math mode

For inline math mode, the delimiters $latex ... $ and \( ... \) are functioning. But I like to use the single dollar sign: $ ... $ to activate inline math mode. If possible, how can I do it?

Also, it would be great if the syntaxes of inline and display math delimiters could be chosen/specified by users from the plugin settings.

Don't use extract()

Currently, the latex_shortcode() method uses extract. WP standards recommend not using this:

----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 155 | WARNING | extract() usage is highly discouraged, due to the
     |         | complexity and unintended issues it might cause.
----------------------------------------------------------------------
public static function latex_shortcode( $atts, $content ) {
    self::$add_script = true;

    // this gives us an optional "syntax" attribute, which defaults to "inline", but can also be "display"
    extract( shortcode_atts( array( 'syntax' => get_option( 'kblog_mathjax_latex_inline' ) ), $atts ) );
    if ( 'inline' === $syntax ) {
        return '\(' . $content . '\)';
    } else if ( 'display' === $syntax ) {
        return '\[' . $content . '\]';
    }
}

Add Schema.org accessibility metadata to enable discovery of accessible math content

Encapsulate math expressions with the new Schema.org accessibility properties that indicate the use of MathML or LaTex, so search engines can identify pages that have accessible math.

http://a11ymetadata.org

Example:
< span itemscope itemtype="http://schema.org/WebPageElement">
< meta itemprop="accessibilityFeature" content="latex">
< meta itemprop="accessibilityFeature" content="MathML">
< div class="MathJax_MathML" id="MathJax-Element-1-Frame">
...
< /div>
< script type="math/tex; mode=display" id="MathJax-Element-1">df(X_t)= \sum_{i=1}^d f_{,i}(X_t),dX^i_t + \frac{1}{2}\sum_{i,j=1}^d f_{,ij}(X_{t}),d[X^i,X^j]_t</script >
< /span >

Though, the source is in LaTex, because MathJax allows you to get the corresponding MathML, I have also tagged the formula as being available in MathML.

http://www.dessci.com/en/products/mathplayer/manual.htm#mathjax

Compatibility with WordPress 6

Just upgraded my blog to WordPress v6.

The plugin is configured with 2.7.5.

This is my test post for the plugin.

It is working correctly as expected.

I'm happy to do more testing.

What I am thinking is to create a page with a lot of examples on it.

Undefined control sequence \cfrac and \dfrac

I'm trying to use the \cfrac and \dfrac command in my posts but it seems that the AMSMath extension is not enabled? Can you please let me know how I can enable the AMSMath extension so that I can use these commands?

Add fields to support extensions

I really like the plugin as it handles the loading of the mathjax code quite well, but for some projects, you may want to add extensions such as mhchem.

Wouldn't it be great if you could remove and add these packages in the WordPress backend instead of hardcoding them by yourself?

Deploy new release to wp.org

Hi,

I don't think the most recent new release has been deployed to wordpress.org.

As a result, the update doesn't show up in WP admin page.

Could you please fix this?

Thanks!

vertical alignment

Hello,

I am new to the plugin, and unexperienced in WordPress. I just activated the plugin, and notice the problem that the latex equations are displayed vertically above the typical line elevation.

See all equations here, and attached screenshot-close-up.

Is there a setting for the vertical alignment?

line_elevation_latex_mathjax

Fatal error activating Mathjax plugin in WordPress

Hi,

The Mathjax could not be activated for it triggered a fatal error.

Parse error: syntax error, unexpected '[' in /.../wp-content/plugins/mathjax-latex/class-mathjax-latex.php on line 29

In class-mathjax-latex.php, it is

26 class MathJax_Latex {
27 public static $add_script;
28 public static $block_script;
29 public static $mathml_tags = [
30 'math' => [ 'class', ...

I am using WordPress 4.9.8. Is there anyone who would like to help me?

Kind regards,
MatrixC7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.