liffiton / dokuwiki-plugin-mathjax Goto Github PK
View Code? Open in Web Editor NEWMathJax plugin for DokuWiki
Home Page: https://www.dokuwiki.org/plugin:mathjax
MathJax plugin for DokuWiki
Home Page: https://www.dokuwiki.org/plugin:mathjax
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.
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
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
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.
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!
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.
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?
Good day! There is a problem with plugin in Dokuwiki "Greebo". I have installed it. This code added to the page:
But formulas did not render. For example, I wrote
Is it possible to fix this?
The config file mentioned on DokuWiki doc for AsciiMath, is not valid. Does anyone know of another config file/CDN path to make both TeX and AsciiMath work for this plugin?
"Show Math As" > "Tex Commands" displays the correct code
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.)
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 =====
In Chrome, "Typesetting math: 100%" gets printed, the cpu load goes and the browser suggests to kill the window for not being responsive anymore.
I think I had already opened this issue but can't find it in the tracker ...
Mathjax doesn't render when used in presentation mode (plugins S5 and revealjs), except for one configuration: revealjs in Safari!
See this page in S5 presentation mode and revealjs presentation mode.
My question now is: What needs to be fixed to bring the Safari experience to all browsers?
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.
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?
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
(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
The Rackspace address will be retired soon and the MathJax CDN now supports direct SSL access. See http://www.mathjax.org/changes-to-the-mathjax-cdn/
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).
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`%%
The protecttex
functionality needs to be expanded to cover AsciiMath delimiters as well.
The formula with a ampersand:
$$ a &= 1 \\ b &=1 $$
cause a error.
Version Dokuwiki: Release 2020-07-29 "Hogfather"
Plugin version: 2021-05-23
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
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:
Any idea why this is happening?
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; }
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.
SEE: https://www.mathjax.org/cdn-shutting-down/
The default value of the plugin will cause problems.
plugin should provide local / alternative host option menu ...
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 :
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]
}
}
});
Is this a bug or I'm missing something in the matjax configuration file ?
Thanks
Firefox doesn't render math formulas at all but prints them as plain text. No javascript errors were reported.
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):
%%\begin{equation*}
f'' + g''
\end{equation*}%%
$ $
, $$ $$
, \[ \]
, and \( \)
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.
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:
$
or $$
$
) delimitersWhat 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!
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 ======
====== Convertir un binaire à un hexadécimal ======
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.