Allow wiki owner to customize the meaning of $$ and other shortcuts
Status: Beta
Brought to you by:
worden
If you want to use $...$ for inline math, and $$...$$ for block math, it would be simple if I had a $ww variable defining those replacements, rather than having them hardcoded. This would also allow some wikis to use itex or other processing engines in place of latexml, since some wikis like that sort of thing.
Anonymous
Done. We now have $wwWikitextReplacements for this. Here's an example of how it's used:
This is a bit hard to read, but works. The key is a regular expression, and the value is the string that replaces it. The 'e' modifier at the end of the regexp causes it to evaluate the replacement string as php code, executing the
md5()
function to generate a hash value from the input string. This has the effect of replacing'$...$'
by'<source-file filename="(hash).itex-math" standalone="yes">$...$</source-file>'
.When used together with
and a make rule transforming
%.itex-math
to%.itex-math.html
, this will cause WW to process all $...$ constructions by runningitex2MML
or whatever scripts to make the content into HTML for display in the browser.Using $wwWikitextReplacements to implement latex-style
$...$
with single dollar signs does indeed cause havoc in places. For example in Special:RecentChanges, it uses Message::rawParams() to inject message parameters after parsing, which means the message goes to parsing with the placeholders$1
,$2
,$3
intact. Which means the WW wikitext replacement goes and garbles it up, and instead of seeing "Show last 50 | 100 | 250 | 500 changes", you get "Show last Removed missing source file '7f01911944a5e25d80eb076646bc12dd.itex-math' from project".I'm pretty sure the solution to that is you can't substitute
/\$(.*?)\$/
while parsing wikitext. It might be possible to fix this by defining a WW Wikitext content type in alternative to the standard wikitext content type, defining all pages to be that content type, and doing the replacement on that, so that things that actually are standard wikitext, such as system messages, don't get messed with.