Menu

#521 Allow wiki owner to customize the meaning of $$ and other shortcuts

workingwiki
open
None
5
2014-07-19
2014-04-02
Lee Worden
No

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.

Discussion

  • Lee Worden

    Lee Worden - 2014-04-17

    Done. We now have $wwWikitextReplacements for this. Here's an example of how it's used:

        $wwWikitextReplacements['/([^\\\\]|^)\$(.*?[^\\\\]|)\$/e'] =
           "\"$1\".'<source-file filename=\"'.md5('\$$2\$')"
           . ".'.itex-math\" standalone=\"yes\">"
           . "\$$2\$</source-file>'";
    

    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

        $wwDisplayTransformations['/\.itex-math$/i'] = '.itex-math.html';
    

    and a make rule transforming %.itex-math to %.itex-math.html, this will cause WW to process all $...$ constructions by running itex2MML or whatever scripts to make the content into HTML for display in the browser.

     
  • Lee Worden

    Lee Worden - 2014-04-17
    • summary: Allow wiki ownder to customize the meaning of $$ and other shortcuts --> Allow wiki owner to customize the meaning of $$ and other shortcuts
    • status: open --> closed
     
  • Lee Worden

    Lee Worden - 2014-07-19
    • status: closed --> open
     
  • Lee Worden

    Lee Worden - 2014-07-19

    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.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.