18

As most of the users may know, we developed a language extension for google-code-prettify to support the correct highlighting of Mathematica code on mathematica.stackexchange.com and is hosted at Github. Currently, this extension can be tested by installing it as local JavaScript-plugin into your browser. A detailed discussion of the features can be found here and here.

During the last weeks of our public beta we were able to fix many bugs and the now the language extension runs amazingly well. The maintainer of google-code-prettify already showed interest to include this in the official release but currently he seems to be quite busy.

Question: Which person of the stackexchange team could help us to setting up the language extension on the server, so that every visitor of the site has correct highlighting of the code?

In detail and only AFAIK this means, he/she needs to put the JavaScript file of the extension (which I would provide) into the prettify directory on the server and the default language should be set to Mathematica.

2
  • 6
    I'll go poke around in this. Thanks for the update on the situation! The persons who can include this would be those on the dev staff, so I'll go let them know about this and see what they think.
    – Grace Note StaffMod
    Feb 24, 2012 at 15:15
  • @GraceNote It's been close to a month since this was posted. Is there anything the SE team needs before this can move forward? What can we do to speed things up? The script is practically ready...
    – Szabolcs
    Mar 20, 2012 at 8:29

1 Answer 1

13

You (and all people involved) have done a great job; thanks a lot for that. With a few minor changes, I'm very happy to include it, and will do so shortly have done so. A few notes though:

  • We will not include it on Stack Overflow, only here on mathematica.se. There are several reasons for this.

    1. Most Mathematica activity has moved over from SO to this site (in the past two months, SO received ~80 questions tagged "mathematica"; mathematica.se got close to 700), so it doesn't seem too necessary.
    2. Since apparently a majority of Mathematica users expect the default client's default syntax highlighting colors, you have changed the colors to match. I am fine with this for mathematica.se, but it's not acceptable for SO. For some details on this, see this chat conversation between me and Szabolcs.
    3. It is huge. Since it includes all named characters and all keywords (of which there are lots), your Mathematica highlighter is very precise, but this comes with a cost. For perspective: If we included it in our regular prettify JavaScript file (which is served to almost all of the millions of visits that Stack Overflow gets every day), it would more than triple that file's size. And that's after gzipping. The low Mathematica activity on SO doesn't justify this.
  • Before we can activate it, you (and any contributors) will have to put it under a license that allows us to use it, which is currently not the case.

That being said, thanks again for the great work; I'm looking forward to activating it.

15
  • 1
    Great news! Thank you! Please, if possible, do give some notification when this goes live so those of us who have the userscript installed can deactivate it.
    – Szabolcs
    Apr 27, 2012 at 9:58
  • @Szabolcs The notification will most likely be in the form of status-completed :)
    – rm -rf Mod
    Apr 27, 2012 at 19:17
  • @balpha, your points are all valid and believe me, I expressed the same arguments very intensively during many chats. Then we decided to build a highlighter which is as nice as possible for the Mathematica users and here it is. I'm perfectly fine with not putting it on Mathematica.SO because breaking the conventional coloring there is bad. Even the file size gave me a headache too while there were more requests what additional nice to haves we could put in. Simple question: What license do you need to use the code? Where do I have to put it? Only in the header?
    – halirutan Mod
    Apr 28, 2012 at 1:45
  • @halirutan We're not really picky about legal stuff, so don't worry too much :) We just need something that tells us that we're fine to use the code. Only allowing us to do that would work, but be pretty weird. An often-used license for JS libraries would be MIT (that's what we use for most our open source stuff); BSD or Apache are similar (prettify itself is Apache licensed). Those are liberal licenses; from the copy-left category, the LGPL may work as well (but only 3 people in the world really understand that license).
    – balpha StaffMod
    Apr 28, 2012 at 9:47
  • @halirutan Regarding "where to put it", the standard way is to put a blurb at the top of the source file(s) (like here) or add a LICENSE.TXT file to the repository. Anything is fine. We don't run stuff like this by lawyers :) Thanks again.
    – balpha StaffMod
    Apr 28, 2012 at 9:49
  • @balpha, please find now a file lang-mma.js in the repository which is a google-code-prettify language extension without Tims plug-in code. I diffed the two files again to ensure the essential parts are the same. Additionally, you can find a prettify-mma.css file which has the same structure as the style files in the prettify distribution but which contains the Mathematica coloring. And of course I added the license information to our script files.
    – halirutan Mod
    Apr 29, 2012 at 1:43
  • @balpha, please note that the css file does contain a section for the printing style which only differs from the display style in bold keywords. I'm not sure whether it is a good idea to leave the same colors there. On my b/w laser printer it would have looked nicer if only black was used. I'm sure you had this problem before and can just solve it the same way.
    – halirutan Mod
    Apr 29, 2012 at 1:48
  • @halirutan Looks good; I've tested it locally and it works great. You might want to change the copyright notice, unless your name is "Google Inc." and you wrote this in 2009 :) I'll activate it after the next build of the site.
    – balpha StaffMod
    Apr 29, 2012 at 9:33
  • Aehmm, yes. I just copied it and didn't even look at it ;-)
    – halirutan Mod
    Apr 29, 2012 at 11:42
  • 1
    @halirutan and balpha : as R.M. noticed, patterns are no longer highlighted in green as they should be (and as they were in the userscript). For example, in this post, minD[j_] should have j_ in green and in italics.
    – Szabolcs
    May 6, 2012 at 10:31
  • 1
    @halirutan and balpha: strangely _Real is highlighted correctly, but x_ is not. (Both worked with the userscript.)
    – Szabolcs
    May 6, 2012 at 12:16
  • @szabolcs: My test-environment here at home is the google-prettify package which I downloaded when we start the project; beginning of 2012. I developed the code purely using the lang-mma.js script and only copied it into the user-script when I published it for you. Here, everything works as expected. How can we track this issue? balpha, should I send you my complete package? Or does it work locally for you too?
    – halirutan Mod
    May 6, 2012 at 22:55
  • @halirutan Do you see the problem here on the site as well? The problem is there at least in in Firefox 12, Chrome 18 and IE 8. So far I only noticed the breakage with x_ style patterns. _Integer and opt : OptionsPattern[] seems to work fine.
    – Szabolcs
    May 7, 2012 at 11:54
  • @Szabolcs, yep. I deinstalled the user-script and have the same behavior, that x_ is not highlighted correctly.
    – halirutan Mod
    May 7, 2012 at 12:35
  • @Szabolcs, please look here: meta.mathematica.stackexchange.com/q/388/187
    – halirutan Mod
    May 8, 2012 at 2:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .