Coder Social home page Coder Social logo

dokuwiki-plugin-mathjax's Introduction

MathJax Plugin for DokuWiki

Enables MathJax parsing of TeX math expressions in wiki pages
(See https://www.mathjax.org/)

All documentation for this plugin can be found at
https://www.dokuwiki.org/plugin:mathjax

If you install this plugin manually, make sure it is installed in
lib/plugins/mathjax/ - if the folder is named differently, it
will not work!

Please refer to https://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) Mark Liffiton <[email protected]>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

See the COPYING file in your DokuWiki folder for details

dokuwiki-plugin-mathjax's People

Contributors

jean-michel-gonet avatar klap-in avatar liffiton avatar sklrrzn avatar splitbrain avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

dokuwiki-plugin-mathjax's Issues

Problem: Subtitle not recognized after MathJax

When i create a new Subtitle in an article after entering a MathJax Code the Subtitle is not recognized by Dokuwiki.

Example:

====== Lorem ipsum ======
===== Lorem ipsum =====
==== Lorem ipsum ====
Lorem ipsum $f(x) = -2x^3 + x^2 - 2x + 5$\\
Lorem ipsum: $\lim\limits_{x\to\infty} f(x) = \lim\limits_{x\to\infty} -2x^3 + x^2 - 2x + 5$
Lorem ipsum:
$$\begin{align}
\lim\limits_{x\to\infty} f(x) & = \lim\limits_{x\to\infty} -2\color{red}{x^3} + x^2 - 2x + 5\\
& \approx \lim\limits_{x\to\infty} - 2\color{red}{x^3}\\
& = -\infty
\end{align}$$ -

==== Lorem ipsum ====
Lorem ipsum $\lim\limits_{x\to-\infty} f(x) = \lim\limits_{x\to-\infty} -2x^3 + x^2 - 2x + 5$\\
Lorem ipsum:
$$\begin{align}
\lim\limits_{x\to-\infty} f(x) & = \lim\limits_{x\to-\infty} -2\color{red}{x^3} + x^2 - 2x + 5\\
& \approx \lim\limits_{x\to-\infty} - 2\color{red}{x^3}\\
& = -*(-\infty)\\
& = \infty
\end{align}$$ $

===== Lorem ipsum =====
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
$$\begin{align}
f(x) & = \frac{3x+2}{x}\\
& = \frac{3\color{red}{x}}{\color{red}{x}} + \frac{2}{x}\\
\lim\limits_{x\to\infty} & = 3 + \frac{2}{x} & \frac{2}{\infty} \Rightarrow \color{blue}{0}\\
\lim\limits_{x\to\infty} & = 3 + \color{blue}{0}\\
\lim\limits_{x\to\infty} & = 3
\end{align}$$

===== Lorem ipsum =====

Enable only on certain pages

Is there a way to only enable the plugin on certain pages/namespaces of a wiki? And not load it at all on the other pages?

Multiple mathjax in one page seems to cause a problem

Hello,

I've created the following page and for some reason the parser of dokuwiki doesn't seems to interpret the third header after using a mathjax expression.

EDIT: For some reason, Github is not displaying "newline" (double backslash) properly.
Thanks.

My page:

====== Codage, langage machine, instructions ======

Base 10: 1, 10, 100, 1000, ..
Base 2: 1, 2, 4, 6, 8, 16, ..

====== Convertir un décimal à un binaire ======

$$ \begin{align} 19 _ {10} &\geq 16, \text{ oui } = 1 \text{ , il reste } 3 3 _ {10} &\geq 8, \text{ non } = 0\text{ , il reste } 3 3 _ {10} &\geq 4, \text{ non } = 0\text{ , il reste } 3 3 _ {10} &\geq 2, \text{ oui } = 1\text{ , il reste } 1 1 _ {10} &\geq 1, \text{ oui } = 1\text{ , il reste } 0 19 _ {10} &= 10011 _ {2} \end{align} $$

====== Convertir un binaire à un hexadécimal ======

$$ \begin{align} & 0010 \space 0011 & 2 \space\space\space\space\space\space\space 3 & 23 _ {16} \end{align} $$

Headers break when {alignment*} is used

(I am using MathJax plugin, Date: 2014-07-22, on Dokuwiki Release 2013-05-10 "Weatherwax")

This alignment blog breaks the headers below, if they are followed by further display equations:

$$
\begin{align*}
D_{i} & := a
\end{align*}
$$
==This header displays as text, it is broken==
Broken example because align block above and equation below:
$$ x = \int y$$

Note that if there are no further display equations it works fine:

$$
\begin{align*}
D_{i} & := a
\end{align*}
$$
==This header displays fine==
This works

Mathjax display overlays onto table of contents.

Hi,

I have noticed the plugin seems to conflict with the table of contents div, see screenshot:

screen shot 2016-03-28 at 12 37 56 pm

You are unable to click the links in the ToC under the mathjax display div. If I was competent in CSS I'd provide a patch, but alas.

Russ

Mathjax does not work in IE8

First of all: Great plugin!

Mathjax does not work in IE8 (XP and Windows 7). It causes the error below.
It works fine in Firefox 13.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; MS-RTC LM 8)
Timestamp: Thu, 5 Jul 2012 20:53:26 UTC

Message: Syntax error
Line: 1
Char: 6
Code: 0
URI: ******/dokuwiki/doku.php?id=playground:playground

Conflict with the mathjax plugin

When I edit an equation block as follows, it will change the double backslash to a single backslash. It would be perfect if it can recognize equation blocks and disable the escaping. (There might be other characters that are similarly escaped and transformed without my noticing.)

$$ \begin{aligned} abc &= def \\\ abc &= def \end{aligned} $$

seems not supporting IE9

Hi there,
I have mathjax installed in my server and then install the plugin-mathjax to incorporate that into the wiki. It works great in firefox, chrome and few other browers. But when I come to IE9, the math fail to show. I try all the ways as mentioned in the help of mathjax regarding IE, no help. But when I visit the home page of mathjax, I saw the math. Also, visiting the test page in the installed folder always show the math in IE too. So I am just wondering if this is something due to the plugin or not.

any way to insert numbered equation?

While I am reading the documentation of mathjax, I think it supports \begin{equation} environment but when I use the plugin in dokuwiki for mathjax, seems \begin{equation} doesn't work.

Different rendering with renewcommand in config file than directly used

Thanks for the plugin. I like my vector to be in bold. I ussualy redefine the latex \vec{} command :

If i put

$\renewcommand\vec[1]{\mathbf{#1}}\vec{AA'}$

inside a dokuwiki page i get :
image

If I put in on the mathax config file above :

MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ["$","$"], ["\\(","\\)"] ],
        displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
        processEscapes: true
    },
    TeX: {
        Macros: {
          RR: '{\\bf R}',
          bold: ['{\\bf #1}',1],
          vec: ['{\\mathbf #1}',1]
        }
    }
});

I get :
image

Is this a bug or I'm missing something in the matjax configuration file ?

Thanks

Popup for footnotes doesn't show maths properly

Popup window for footnotes which is shown when the mouse hovers over it doesn't show MathJax maths correctly. Footnote itself, shown at the bottom of the page, has no problem.

Markup like this:

 * Math $\sqrt{x^2+y^2}$
 * Footnote math:
((Footnote: $\sqrt{x^2+y^2+z^2}$))

ends up like this:

image

Any idea why this is happening?

render content in <math> tags

Hi!

I recently converted over a bunch of mediawiki sites which use the tag to render latex formulas. Is there a config setting to also register this tag?

Thanks!

AsciiMath not fully supported

Issue

Using a configuration that supports AsciiMath (e.g., https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML.js), the plugin does render AsciiMath, but there are issues. Complex formulas run into issues with DokuWiki parsing things in the AsciiMath (like (( ... )) for Dokuwiki footnotes) and breaking things. The plugin is not currently setup to "protect" the AsciiMath within AsciiMath delimiters (the backticks).

Workaround

You can work around that by putting the AsciiMath in %% to make Dokuwiki skip trying to parse it. So this works for me with the URL/config linked above:

%%`sum_(i=1)^n i^3=((n(n+1))/2)^2`%%

Needed fix

The protecttex functionality needs to be expanded to cover AsciiMath delimiters as well.

Use an own instance of mathjax

Hey, is there a way to integrate an option in the next plugin version where i can enter the URL of my own mathjax instance? At this time i have changed it in my default config file, but for other users it mighty be easier to enter it on an web fronted.

Thank You

Latest update degrades mark-down

Hi,

I use the plugin markdowku I find it super useful. Unfortunately after a bit of tracking stuff down I found out the latest version of your MatJax plugin causes the quoted things like SomeFunction ie:

   `SomeFunction`

to render as `SomeFunction` instead of SomeFunction as markdown should.

I don't know if markdowku is actively maintained so much now but it is a fantastic plugin as is this one. It would be nice if they didn't conflict!

Thanks!
Jason

Some TeX still not protected from Dokuwiki parsing

Commit 8c54b56 protects several math environments from Dokuwiki parsing, but it doesn't catch all of them. For example, \begin{equation*} environments are not protected.

Example:

\begin{equation*}
f'' + g''
\end{equation*}

Dokuwiki will see the '' marks and format the text in between as monospace, preventing MathJax from seeing and rendering the TeX.

Ideally, this plugin would be able to parse the MathJax configuration and know exactly which environments to look for and protect, but this is likely too complex, nevermind the fact that much of the configuration can be in a file fetched from the CDN and not in the plugin's configuration. Therefore, it's probably best to simply protect more known TeX math environments. If this plugin is installed, it is highly unlikely that one would be writing TeX math that one wants Dokuwiki to parse.

Workarounds (for now):

  1. Protect math environments manually. E.g.,
%%\begin{equation*}
f'' + g''
\end{equation*}%%
  1. Stick to already-protected TeX syntax: $ $, $$ $$, \[ \], and \( \)

Using ampersand cause error

The formula with a ampersand:

$$ a &= 1 \\ b &=1 $$

cause a error.

Version Dokuwiki: Release 2020-07-29 "Hogfather"
Plugin version: 2021-05-23

HTML5 validation failure

The w3c validator yields this error:

Element script must not have attribute charset unless attribute src is also specified.

This applies to lines 33 and 46 of action/enable.php, I guess.

Upgrading the plugin to MathJax v3

Pull request #36 contributes some changes that make the plugin work with MathJax v3 instead of v2. v3 has a slightly different way to insert MathJax into a page, and it's not compatible with v2. To upgrade the plugin cleanly, then, we have to be careful about not breaking things for any existing users with customized setups using v2.

Auto-detecting the version feels way too fragile, and it's not feasible in some cases (e.g., self-hosting the libraries with no version in the path). Adding a configuration option to choose between the two versions sounds nice, but the default value should be to use 3.x, and that would make any existing plugin users have that setting. I don't know how to add a new configuration option to the plugin with a default that only applies for a new install and not an upgrade...

One option would be to create a new configuration option like 'url_v3' or similar and set its default to be a CDN URL for Mathjax v3. Then set the existing 'url' option's default to be an empty string. The plugin could do v2-compatible things if the existing 'url' option is set (meaning the user customized it); otherwise, do v3-compatible things. I think the same thing would have to be done for the 'config' option as well. This ends up being unwieldy for the common case, though, with confusing leftover configuration options that aren't used in most cases.

If there are no good options here, it might be best to just release a mathjax3 plugin separately and direct people to it instead of this one. I don't see any critical improvements in v3 for the use case of this plugin, so letting existing installs linger on v2 doesn't cause any harm. (Correct me if I'm wrong, but the only v3 change I see that's relevant to the use here is that it renders faster.)

Ideas are welcome.

math doesn't render on https pages

I just installed this plugin and it works great for unsecured http pages, but when I view the same page once I am logged in, instead of seeing the rendered math I instead see the source LaTeX. It seems that this can be fixed by following the directions here:

http://www.mathjax.org/resources/faqs/#problem-https

For example, when I go to www.dokuwiki.org/plugin:mathjax, the connection seems to default to https (even though I am not logged in), and all the math appears unrendered.

Presumably if you host Mathjax yourself this problem doesn't occur.

Possible incompatibility with the Markdown plugin

Hi,
I use this markdown plugin on my DW instance and wanted to try your MathJax plugin.
There seem to be a problem with underscores. I do not claim that this is a bug in your plugin, but ask for some help!

I already tried to tweak the getSort value with no luck. I'm not strong enough in DW internals to fully understand the problem. The markdown plugin has 20+ files with different getSort values, ranging from 8 to 219.
If I understand correctly, getType returning protected should prevent this very problem.

You can try yourself to tweak a page where both are installed:
http://galerie.microalg.info/profgra:tests:mathjax

markdowku/syntax/italicunderline.php:14:    function getSort()  { return 79; }
markdowku/syntax/anchorsinline.php:14:    function getSort()  { return 102; }
markdowku/syntax/codespans4.php:14:    function getSort()  { return 96; }
markdowku/syntax/anchorsreference.php:18:    function getSort()  { return 102; }
markdowku/syntax/references.php:15:    function getSort()  { return 100; }
markdowku/syntax/olists.php:15:    function getSort()  { return 09; }
markdowku/syntax/imagesreference.php:18:    function getSort()  { return 102; }
markdowku/syntax/escapespecialchars.php:16:    function getSort()  { return 61; }
markdowku/syntax/imagesinline.php:14:    function getSort()  { return 101; }
markdowku/syntax/linebreak.php:14:    function getSort()  { return 139; }
markdowku/syntax/blockquotes.php:12:    function getSort()  { return 219; }
markdowku/syntax/ulists.php:15:    function getSort()  { return 09; }
markdowku/syntax/codespans2.php:14:    function getSort()  { return 98; }
markdowku/syntax/codespans1.php:14:    function getSort()    { return 99; }
markdowku/syntax/boldasterisk.php:14:    function getSort()  { return 69; }
markdowku/syntax/autolinks.php:14:    function getSort()  { return 102; }
markdowku/syntax/hr.php:17:    function getSort()  { return 08; } /* Before list block parsing. */
markdowku/syntax/headeratx.php:14:    function getSort()  { return 49; }
markdowku/syntax/codeblocks.php:14:    function getSort()  { return 199; }
markdowku/syntax/codespans5.php:14:    function getSort()  { return 95; }
markdowku/syntax/githubcodeblocks.php:19:    function getSort()  { return 91; }
markdowku/syntax/italicasterisk.php:14:    function getSort()  { return 79; }
markdowku/syntax/headersetext.php:16:    function getSort()  { return 49; }
markdowku/syntax/codespans3.php:14:    function getSort()  { return 97; }

any chance to get ASCIImath syntax working?

I'd like to migrate all the math in my wikis from ASCIImath (asciimathml plugin) to mathjax in order to get a better compatibility across browsers. Since MathJax can handle asciimath syntax that should be possible without converting all my formulas, but I can't get it to work.

What I've done:

  • installed the mathjax plugin
  • disabled the asciimath plugin
  • typed some stuff using the default delimiter $ or $$
  • typed some stuff using the backtick (```) delimiter
  • typed some stuff using the backtick (```) delimiter inside default ($) delimiters

What I expected: math parsed with asciimath syntax (same result as with the asciimathml plugin)
What I got (see attached image): no math at all or wrong parsiong (math as tex syntax)

Is there some way to use asciimath syntax with the mathjax plugin?

Thanks!

asciimath

Plugin doesn'r render formulaes

Good day! There is a problem with plugin in Dokuwiki "Greebo". I have installed it. This code added to the page:

default

But formulas did not render. For example, I wrote $x_1=a^2+b^2$ and this text displayed without any changes on my page.
Is it possible to fix this?

Garbage in wiki pages, preventing MathJax from running plus information leak

Hi,

I have set up a fresh dokuwiki wiki with the latest released version of the MathJax plugin. In short: it does not work. No rendering takes place whatsoever. I had a look at the HTML source and there is something which caught my attention:

[...]

<script type="text/x-mathjax-config">/*

Copy & Paste didn't really work: what I wanted to show you is some kind of binary garbage between <script>....</script>. It includes(!) a directory listing of my dokuwiki home directory!! That's a security problem.

I figured out that this is caused by the following php code in ./lib/plugins/mathjax/action/enable.php:

    // Include config files, if any specified
    $configfiles = $this->getConf('configfile');
    $files = explode(';', $configfiles);
    foreach ($files as $f) {
        $f = trim($f);
        $contents = file_get_contents(DOKU_INC . $f);
        if ($contents) {
            $event->data['script'][] = array(
                'type'    => 'text/x-mathjax-config',
                '_data'   => "\n// " . $f . "\n" . $contents,
            );
        }
    }

When I disable the foreach loop, this binary garbage does NOT appear.

Also, I figured out that when i DO define a mathjax config file, it also works fine. My guess is that the case 'no config file defined' needs some kind of special handling. Because in this case the code will, when $configfiles is empty, try to read the root_directory_of_the_wiki. (On FreeBSD for example you can open and read directories just like files). This will cause a binary-mangled directory listing to be included in the Wiki pages and this prevents the Javascript from running.

Would be great if this could be fixed. I'm not fluent in php at all. Thank you very much!
m.

Display errors in Firefox

Firefox doesn't render math formulas at all but prints them as plain text. No javascript errors were reported.

Formulas disappeared after server migration (found to be: conflict with latexit plugin)

After a server migration from PHP 5.6.40 to PHP 7.4.10 the MathJax plugin stopped working. While the MathJax JS loads fine the whole LaTeX environments are deleted entirely from the produced HTML files. I suspect something in 'syntax_plugin_mathjax_protecttex' goes wrong in the new PHP version and removes the LaTeX environments instead of protecting them. Any help is appreciated.

PS: This issue+fix could be related: https://stackoverflow.com/questions/43242929

mhchem extension broken

I want to add chemical formulas and equations to my Wiki. I'm using the MathJax plugin with the following configuration:

MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ["$","$"], ["\\(","\\)"] ],
        displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
        processEscapes: true
    },
    TeX: {
        equationNumbers: {autoNumber: "AMS"},
        extensions: ["AMSmath.js","AMSsymbols.js","mhchem.js","noErrors.js","noUndefined.js"]
    }
});

However, it seems that the plugin isn't working quite properly: when, for example I type a reaction with text above the arrow like so:
$\ce{Zn_{(s)} + Cu^{2+}_{(aq)} ->[{H_2O}] Zn^{2+}_{(aq)} + Cu_{(s)}}$
I get this:
https://imgur.com/aSubnbH

while in reality I should be getting this, as rendered by KaTeX with mhchem in Joplin:
https://imgur.com/8kBdNMx

And this isn't the only odd behavior. Another example: <=> renders as "⇔" while instead it should render as "⇌".

Does anyone have an idea why mhchem is "working" but not quite with MathJax?

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.