How to embed maths in MediaWiki - math

I'm trying to transfer some maths content from and old wiki to my new MediaWiki.
The old page uses MathJax, and looks like this:
Here is the k-degree Taylor series for [[$ f(x) $]]
expanding around [[$ x=0 $]]
[[$ T_k(x) = f(0) + x\cdot f'(0) + \frac{x^2}{2!} f''(0) + \dots
+ \frac{x^k}{k!} f^k(0) $]]
This is what I've found so far:
http://www.mediawiki.org/wiki/Extension:MathJax -- appears to be discontinued.
http://www.mediawiki.org/wiki/Extension:SimpleMathJax -- I tried this and it works on OSX Chrome but gives rendering errors on OSX FireFox (https://github.com/jmnote/SimpleMathJax/issues/1)
http://www.mediawiki.org/wiki/Extension:Math -- this appears to be where the active development is occurring, but I haven't managed to get it working. Also it is a huge headache.
Have I missed anything?
What's the right way to enable maths content in a MediaWiki?
From what I can see, it is looking like: "render on server and provide PNG is faster, render on client using MathJax is simpler/cleaner"
SimpleMathJax is an absolutely minimal install. If only it worked on Firefox!
Math extension is looking like hard work, it looks like overkill -- it seems to support at least 4 different techniques for rendering.

A year after, the situation is getting even more confusing about how MediaWiki sites could process maths. If we all agree that texvc and maths formula displayed in png images are ugly and obsolete, it seems that Mathoid, according to https://www.mediawiki.org/wiki/Extension:Math, "is the most recommended option; Mathoid is the rendering mode that will be used on Wikipedia in the future.” .
But Mathoid requires an external server like Parsoid and they both (Mathoid and Parsoid) are in an heavy development. Therefore I looked for an other solution and found and tested successfully 'SimpleMathJax' (https://www.mediawiki.org/wiki/Extension:SimpleMathJax). It can be set like below
wfLoadExtension( 'SimpleMathJax' );
// MediaWiki 1.24 or earlier
// require_once "$IP/extensions/SimpleMathJax/SimpleMathJax.php";
works on any recent version of MediaWiki (latest version tested is mw1.28 of late December 2016).
However the code of the extension itself is not distributed with the numerous MediaWiki extensions from the WikiMedia fundation (which supports mathoid) but you can get it on github at https://github.com/jmnote/SimpleMathJax/archive/master.zip and expand it into your extension subdirectory with other extensions.
The math rendering is beautiful because it uses MathJax and MathJax (.org) is "an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers."
Most of the standard AMS LaTeX code seems to work fine (align etc).
It is called "simple" MathJax probably because it doesn't have the ambition of the MW MathJax extension to process all LaTeX and TeX facilities like numbering equations and process TeX macros, but it uses the original javascript CDN of mathjax.org and therefore is very simple to install and to use for short mathematical texts.
- If you want to process longer and even huge mathematical texts, you can try 'pandoc' which will transform your full LaTeX document into mediawiki source with the following command line:
$ pandoc -o foo.wiki -f latex -t mediawiki foo.tex

You do really want https://www.mediawiki.org/wiki/Extension:Math it is the standard way of doing things.
Maths rendering has been a problem on wikipedia for a long time now. The original system uses PNG images dates back to about 2005. It was the best that was available then, but it is really ugly, the font sizes don't match, the base line are all wrong and there is no anti-aliasing. The advantage is that its stable and works for all browsers.
Ever since then there has been attempts to improve the maths rendering. The first attempt was Blahtex which produced MathML but never got traction with the developers.
Then MathJax came along. The first implementation was as a user script
https://en.wikipedia.org/wiki/User:Nageh/mathJax this worked pretty well but needed the user to manually add it to their javascript skin files.
A couple of years ago MathJax got rolled into the main Math extension, with a user preference (off by default).
MathJax is the nicest current rendering but there are two major problems, browser support, it has to work on all possible browsers including the more limited ones on phones and ancient systems. The other is speed, as it is rendered by javascript it takes time to format the equations, this can be up to a minute for the more complex formula rich pages.
MathML is another possible option, however Firefox is the only browser with halfway decent support.
This has led to a problem with making a universal system. The current development is a system which allows client side MathJax/MathML rendering for those who want the best rendering, the old PNG rendering as a fallback and a new system which uses MathJax to render SVG on the server side.
As to what to actually do. I think the simplest is to ignore extensions completely and just use MathJax on the global javascript files. See https://en.wikipedia.org/wiki/Wikipedia:Common.js_and_common.css. This would be a pretty standard MathJax configuration.
Lets look at how the User:Nageh/mathJax script works, and adapt this for your setting. What he did is install a copy of mathjax on the webserver server, in his case it was all installed in his user space
https://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=Nageh%2FmathJax&namespace=2
If you have access to the server you could install the code in a more sensible place. Say for sake of argument MediaWiki/includes/MathJax. Then in common.js just have a line
importScript("/MediaWiki/includes/MathJax/MathJax.js");
or possible better
mw.loader.load("/MediaWiki/includes/MathJax/MathJax.js");
or even better
mw.loader.using("/MediaWiki/includes/MathJax/MathJax.js").done( function() {
MathJax.Hub.Config( ... );
} );
after than just have the MathJax hub setup you need. See https://www.mediawiki.org/wiki/ResourceLoader for details.

Related

VSCode : mvbasic extension on editing Unidata code with MV marks in code, ie CHAR(253), CHAR(254)

I have searched for a setting within the mvbasic extension within VSCode but I may have hit a dead end. I am new to using VSCode with the rocket mvbasic extension and still in the learning process, so please bear with me.
Our development for the most part has always been directly on the server using the editor within it to code and develop on a Unix/Aix platform with Unidata. Some of our code has array assignments with CHAR(253)/CHAR(254) characters within them. See the link to the image that shows how its done. Now I didn't do this code, the original software developer did this many many years ago and we just aren't going to go and change it all.
How code looks on actual server
The issue is when pulling the code to edit in VSCode, the extension is changing it, and I uploaded it back and didn't pay attention and it was implemented in our production incorrectly, which created a few bugs.
ALIST="H�V�P�R�M�D"
How code looks in VSCode
How code looks after uploaded back to server from VSCode
Easy to fix, no biggie, but now to my question.
Does anyone have this issue, or has a direction to point me into that maybe I need to create a setting to keep the characters in the correct ASCII format so that this doesn't happen again by mistake?
VSCode defaults to the sane choice for character encoding in 2022: utf-8, but sometimes you have to deal with legacy stuff.
https://code.visualstudio.com/docs/editor/codebasics#_file-encoding-support
If you click on the UTF-8 in the bottom right corner you can choose "Reopen with Encoding":
After that, you can select a different encoding. I chose DOS (CP437) at a guess and literal MV characters are displayed as superscript 2 (²), and for me I can save to the server and confirm those characters remain as #VM after a round trip (though for my terminal emulator they appear as } which is useful).
You can edit preferences and set "files.encoding": "cp437". One other thing that can be helpful if your programs don't have a standard extension (like .bas) as most don't is to set the default mode to basic so most of what you're editing will identify as MVbasic, and you can do a quick CTRL-K M to switch to any other modes if you're just pasting in something else like SQL.
Some useful links - the Rocket forums are helpful and the folks there are always super nice
https://community.rocketsoftware.com/forums/multivalue?CommunityKey=521bce2e-71d5-4d32-b560-dfa95e950eb5
The MV Extensions Community extension is a good group and always has been helpful when I've had issues. I've made some small contributions - they're very open. I prefer this extension, but honestly haven't done a deep comparison.
https://github.com/mvextensions

CSS-precompiler LESS and/or SASS

Is there a way to avoid working with the command-line installing and using LESS??
There are several offers for GUIs for the compiling-phase, but I did not find a way for the Installation-Phase.
I have been working in the IT-business for so many decades (more in the mainframe and midrange area and as a project-manager and programmer in the application development) and could by now avoid to go as far down to the command-line-world.
I did develop quite fine Websites using HTML5 and CSS3 and doint this I felt a desire for all that, what LESS and/or SASS are offering and the Syntax and logics dont look difficult to handle. But I fail in the first step of just installing it.
The LESS-Website offers command-lines to key in. But I am not sure, if this will be all I have to key in, but only the significant line to be embedded in a sequence of other commands very familiar to all those working at this Level.
How do I e.g. define the place to store the Installation and to refer to in the href in the link-Statement of my html-file .... ??
Thanks
Gerhard (from Vienna/Austria, living in Trier, Germany)
Less is a CSS pre-processor. if you are include less.js in you html page
You can use less directly in to your html page.
Other ways you can use less compiler
Kola this is an open source application it will help you to compile less to css
Your Topics are clear to me. I even downloaded Koala already and I have no Problem in including less.js in my html. And I have read Bass Jobsens book about the Syntax, which does not seem to raise great Problems to me.
But before working with it, I will have to download LESS -what I have done from the Less-Website to the Folder of my choice. My Problem is the next necessary step: To install this downloaded program. There is no install.exe or something like that. The book as well as the info in the less-Website tell me to key some crpytic commands into the command-line.

Compile Finite State Machine to UML(-like) Diagram

Every Python developer knows tools like Sphinx. You write some text in a markup language, write make in the shell and let some compilers do their job. In the end you get beautiful HTML or PDF.
I am looking for something like that, just for Finite State Machines, e.g. I put SCXML into a file (with a GUI or manually with VIM as I desire) start a compiler and out comes a picture file format that i can use however I please and that looks good even if I don't know what I am doing. Example:
$ vim my-fsm.scxml
$ scxml2svg my-fsm.scxml
writing file...
finished writing my-fsm.svg
$
The closest I got so far is using various Eclipse plugins (years ago, dislike huge IDEs), draw.io or what I am using now: Umlet. Even Umlet has problems, though. For example it doesn't support the workflow I am used to (write text files, start compiler, see beautiful result). The results are often also suboptimal, because the engine is actually quite simple. But everywhere I look for a more useful alternative (python wiki, other SO questions, tools) I still don't find a simple compiler.
Now I would be really happy if anybody would know such a compiler. If not possible a FOSS GUI editors with PNG/SVG export would also be okay.
GraphViz has a file format which can be written manually and compiled to different picture formats.
I wrote some tools to do this: http://goo.gl/V97ft

Specifying the font in an R console - multiplatform solutions?

This is fairly mundane as R questions go, but I would like to specify the font in my R console. It's easy enough to do in Windows - John Cook has an excellent little writeup on that.
However, that is specific for the Windows R GUI. I'm not able to find a way to do this (at least from within R) on RStudio, Linux, etc. Is there a global, platform-agnostic solution? If not, what would need to be wrapped to make this feasible given per-platform idiosyncracies?
Or is this infeasible?
Note that I'm interested in the font family, rather than the font size, though font size suggestions are welcome.
Edit: I plan to apply this inside a program, if possible. Since R can make calls to the shell, I am happy with a two-pass method that first configures external files in preparation for a subsequent invocation of R, if that is necessary.
No, each of the front-ends to R are responsible for the way that the console is displayed to the user. This will be inherently platform and front-end specific.
I believe that Gavin is right: this is set per frontend, and I fail to find anything for Linux. However, the standard R frontend for Windows is addressed in my question. Mac users may find this page helpful: Permanently change default console font.
So, the answers as I found them may be summarized as:
Windows / default R - see John Cook's page
Mac - see link above
Linux / default R frontend - not possible (or am I wrong?)
(Windows, Mac, Linux) / Rstudio - Font family is not available (yet) - see this page. Font size is - this page
Windows / Revolution R - this page
Other / Revolution R - not found
So, the universal trick is that I need to use R via a web server, and then I can configure my browser. :) Not going to happen. I'll wait on Rstudio.

LaTeX equivalent to Google Chart API

I'm currently looking at different solutions getting 2 dimensional mathematical formulas into webpages. I think that the wikipedia solution (generating png images from LaTeX sourcecode) is good enough until we get support for MathML in webbrowsers.
I suddenly realized that it might be possible to create a Google Charts API equivalent for mathformulas. Has this already been done? Is it even possible due to the strange characters involved in LaTeX-code?
I would like to hit an url like latex2png.org/api/?eq="E = mc^2" and get the following response:
edit:
Thanks for the answers sofar. However, I am already aware of several tools to generate png images from latex source code (both online and from my commandline), but what I was looking for was a simple way to get the image via an Http GET request. Perhaps such a service does not exist.
Update
As #hughes (and others) pointed out, the previous Google Chart API has been deprecated.
The example I wrote still works as of Sept 2015, but a new one shall be used now (documentation):
Old answer
Google Chart can do it (Documentation):
http://chart.apis.google.com/chart?cht=tx&chl=%5CLaTeX
I'm using this with Google Docs, because it doesn't support math yet.
chart.apis.google with background color changed
https://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFF00&chl=%0D%0A4x_0%5CDelta%28x%29%2B3%5CDelta%28x%29%2B2%5CDelta%28x%5E2%29%3E0%0D%0A
or chart.apis.google with background color transparent and resized
For better readability URL needs to be decoded.
https://chart.apis.google.com/chart?cht=tx&chs=428x35&chf=bg,s,FFFFFF00&chl=
4x_0\Delta(x)+3\Delta(x)+2\Delta(x^2)>0
Data structure looks like this
{
"cht":"tx",
"chs":"428x35",
"chf":"bg,s,FFFFFF00",
"chl":"n4x_0\Delta(x) 3\Delta(x) 2\Delta(x^2)>0"
}
https://chart.apis.google.com/chart?cht=tx&chs=428x35&chf=bg,s,FFFFFF00&chl=%0D%0A4x_0%5CDelta%28x%29%2B3%5CDelta%28x%29%2B2%5CDelta%28x%5E2%29%3E0%0D%0A
You could try the Online image generator for mathematical formulas for a start.
mathurl is a mathematical version of TinyURL.com. It allows you to reference LaTeXed mathematical expressions using a short url. For example, http://mathurl.com/?5v4pjw will show [LaTeX output Image] which you can then edit. More details on mathurl’s help page
I just ran across MathJax on Ajaxian [via Wayback Machine]:
MathJax seems to have a chance at being a practical solution that offers a high quality display of LaTeX and MathML math notation in HTML pages.
The output is remarkably beautiful, and it's all pure HTML and CSS, which makes it scalable and selectable. Performance is currently a bit sluggish, but this is recognized.
As everyone has said, there are many services that do this already. Here is another easy one that I've used a number of times (and you can install it locally on your server if necessary):
http://www.codecogs.com/components/equationeditor/equationeditor.php
I'd take a good look at how the MediaWiki LaTeX support does it and borrow from there.
Please check out this site for a way to create TeX documents without any software installed. You can then snippet the result image with any screen capture method and embed the resulting image into a any website.
Go to http://sharelatex.com
The software is free to use, but you need to register to create documents.

Resources