wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> suggestions, help, and FAQ >> [ FAQ : how to write (and view) math symbols ]
(Message started by: SMQ on Feb 16th, 2007, 8:42am)

Title: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Feb 16th, 2007, 8:42am
WILLYWUTANG AND THE DISAPPEARING MATH SYMBOLS

Willywutang runs an online forum where, among other things, puzzles of a mathematical nature are discussed.  Once uopn a time, Willywu added support in the forum software (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_suggestions;action=display;num=1035249563) for users to easily include a large number of common (and not-so-common) mathematical symbols in their posts.  But then, for performance reasons Willywu upgraded the forum software to a newer version and hasn't had the time to restore his customized math symbol support.  How can Willywu's users still see the intended symbols (instead of obscure text) when viewing old posts and enter math symbols in their new posts?


ANSWER: This User Script (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js)!

A "user script" is a piece of program code which can be automatically run by a web browser to change the way a web page looks or works when it's viewed.  While a few browsers have built-in support for user scripts, most require some sort of add-on software (e.g. Greasemonkey for the Firefox browser) to be installed first, and some can't support them at all (see "What if my browser doesn't support user scripts" below).


HOW TO USE:

Once you have the above user script installed (see "How to Install" below), two things will immediately change: in any old post with math symbols, (e.g. this one (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_medium;action=display;num=1083464351)) you should now see the actual symbol (e.g. http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbr.gif) rather than the text (e.g. [smiley=bbr.gif]); and when editing or creating a post you should see a math symbol "menu" below the row of faces and an "Insert Symbols" checkbox at the bottom.

To use a math symbol in your post, either choose it from the appropriate page of the menu, or, if you know its name (you can see a symbol's name in the menu by hovering your mouse over it, or for those familiar with LaTeX, almost all the built in and AMS symbols should be defined here), simply type a backslash (\) followed by the symbol name and a space (if you want a space between the symbol and whatever comes next, remember to type two spaces after the symbol name).  For example, typing \pi will generate a http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/pi.gif symbol in your post, typing "\sqrt \pi" will give http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/pi.gif, and typing "\sum  \x" (two spaces) will give http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gif http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/x.gif with a space between.  If you're typing symbol names directly, remember to also check the Insert Symbols checkbox below the text as well (if you use the menu the box will be checked automatically).

Finally, if you're quoting a post which used math symbols you'll see them as text (e.g. \pi) in your post (and the Insert Symbols checkbox will be checked for you automatically by defalut), but they will show as proper symbols in the preview and when you submit your post.  That's all there is to it!

Title: How to Install
Post by SMQ on Feb 16th, 2007, 8:43am
HOW TO INSTALL:

If you know you're already using user scripts in your web browser, you can skip these instructions and just click the This User Script link above, and either the script will be automatically installed or you can download and save it in your user scripts directory.  If you've never set up a user script before, follow the instructions in the appropriate section for your browser below (accurate as of 20 August 2007).

If you don't know what web browser you're using, there's a good chance it's Microsoft Internet Explorer if you're on a PC/Windows computer, or Safari if you're on an Apple Macintosh (Mac).  A good place to look is at the very top of the window; the name of the browser will usually be at the start or end of the title bar there.  If you "just click the internet", you're probably using Internet Explorer.

Mozilla Firefox (http://www.mozilla.org/firefox) (version 1.5 or later) and Netscape Navigator (http://browser.netscape.com/) (version 9 or later): the Greasemonkey (https://addons.mozilla.org/en-US/firefox/addon/748) extension for Firefox introduced the concept of user scripts to the world, and is still the most used.
  • Click the Greasemonkey link above
  • Click the Install Now link on that page
  • Click Restart Firefox in the install dialog once the installation is complete.
  • Once Firefox restarts, return to this page and click the This User Script link above; you should see a Greasemonkey Installation dialog, click Install and you're all set.
Microsoft Internet Explorer (http://www.microsoft.com/windows/products/winfamily/ie/default.mspx) (version 6 or later): an extension called Turnabout (http://www.reifysoft.com/turnabout.php) provides user script functionality for Internet Explorer.
  • Click the This User Script link above and save the file to your computer (remember where you saved it).
  • Click the Turnabout link above
  • Look for the Turnabout Advanced link in the Download Turnabout section and click it. (Turnabout Basic doesn't allow you to install your own user scripts.)
  • Either click Run to run the installer directly (and then click Run again in the security warning once it's finished downloading), or click Save to save the installer on your computer, then go to where you saved it and double-click it to start the installation.
  • Take the default installation options (close IE and click Retry if and when prompted by the installer).
  • Once IE restarts, you should see a new toolbar; click the green Reify icon and choose Options... from the dropdown menu.
  • In the options dialog, click the Install Feature... button at the bottom, OK the security information, and open the user script file you saved in the first step; click OK in the options and you're all set.
Opera (http://www.opera.com) (version 8 or later): Opera has built-in support for user scripts, you just have to turn it on.
  • From the Tools menu choose Preferences...; choose the Advanced tab, choose Content on the left and click Javascript Options...
  • Choose a directory for User JavaScript files at the bottom.
  • Now click the This User Script link above, and save the file in the directory you just chose.  You should be all set!
Safari (http://www.apple.com/safari) (version 1.3 or later): an extension called Creammonkey (http://creammonkey.sourceforge.net/) provides user script functionality for Safari.
  • Click the Creammonkey link above.
  • Click the link under download; a disk image will be automatically downloaded and mounted.
  • Open the Library folder in your user directory; if there is not an InputManagers folder there, create one.
  • Copy the Creammonkey folder from the downloaded disk image to the InputManagers folder
  • Close and restart Safari; you should see a new :) item in the menu.
  • Come back to this page and click the This User Script link above; when prompted install the script in Creammonkey and you should be all set.
Epiphany (http://www.gnome.org/projects/epiphany/), Flock (http://flock.com/), Konqueror (http://www.konqueror.org/), SeaMonkey (http://www.mozilla.org/projects/seamonkey/) and others: the user script above should also work in any "modern" web browser that a) supports or has an extension to support user scripts, and b) supports the W3C DOM Specification Level 2 (or later).  The specifics are different on each web browser, but in general you just need to download and install a user script extension then download and install the above user script.

(edited to include Netscape Navigator 9)

Title: What If My Browser Doesn't Support User Scripts?
Post by SMQ on Feb 16th, 2007, 8:43am
WHAT IF MY BROWSER DOESN'T SUPPORT USER SCRIPTS?
(Or what if I'm not comfortable with the quality or security of the user script extension(s) available for my browser?)

Unless William finds the time to restore the old customizations in the forum software there's currently no way to see the symbols in old posts without a user script; however, since the symbol images themselves are still available, you can enter them directly in your own posts the "hard" way: include an image in your post with a url of "http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/{name}.gif" where "{name}" is replaced with the name of the symbol image (not necessarily the exact same name you would use when entering the symbol as text using the above user script!).  For example, http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gif will produce a http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gifsymbol.  For convenience, Icarus has already created a list (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_suggestions;action=display;num=1035249563;start=50#50) (reproduced below) of all the available symbols and their image names for people who have to enter them directly.


LIST OF ALL AVAILABLE SYMBOLS AND THEIR IMAGE NAMES
(note that "biglongdownarrow" and "biglonguparrow" were included by mistake and don't actually exist)

http://www.ocf.berkeley.edu/~wwu/YaBBAttachments/Wu_math_symbols.PNG

Title: Re: What If My Browser Doesn't Support User Script
Post by Grimbal on Feb 16th, 2007, 9:57am

on 02/16/07 at 08:43:51, SMQ wrote:
(note that "biglongdownarrow" and "biglonguparrow" were included by mistake and don't actually exist)

It is ok, it doesn't have to be big and long.

Title: Re: What If My Browser Doesn't Support User Script
Post by Icarus on Feb 16th, 2007, 3:49pm
As I promised, I've made this sticky, and unstuck the old Math Symbols FAQ (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_suggestions;action=display;num=1035249563;start=0#0). Yours is now the official version.

Thanks again for the superb job! 8)

Title: *** New Version 1.1 ***
Post by SMQ on Feb 16th, 2007, 5:59pm
A new version of the user script is available which fixes a rather serious bug where a variety of normal UBB tags (e.g. [b]) were being replaced by their images (!) during editing.

Please make sure you have version 1.1 of the user script installed.

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Sep 21st, 2007, 7:59am
Version 1.2 (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js) of the script is now available.  The only change is that it now resizes the typing area to take up more of the window and give you more room to type.

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by Eigenray on Oct 2nd, 2007, 9:30pm
Preview is non-idempotent: a single '\' character grows exponentially when there are math symbols around.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Oct 23rd, 2007, 8:02am
Version 1.3 (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js) -- the only change is a fix for the multiplying backslashes bug Eigenray noted above.

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by jpixstix on Sep 13th, 2008, 1:12pm
i don't know how to post a new subject so i am replying instead.
Math teacher asked this question:
20+1=19
How do you get this to be correct?
Any info would be appreciated.
Thanks

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Sep 13th, 2008, 1:25pm

on 09/13/08 at 13:12:12, jpixstix wrote:
i don't know how to post a new subject so i am replying instead.
There's a link at the top right of each board called "Start new topic (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_easy;action=post;title=Start+new+topic)", it does exactly as advertised :)


Quote:
Math teacher asked this question:
20+1=19
How do you get this to be correct?
Any info would be appreciated.
Thanks
Usually there's a further constraint like "you can only add one line"; in which case one option is: 20+1 http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/ne.gif19.
Without that further constraint you can do numerous things. For instance you could just move the +1 to the other side.
Or, you could just redefine addition, like: a+b = 19 http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/forall.gif a,b. Or specify you're working in a different than usual area of math: 20+1=19 (mod 2).

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by KeyBlader01 on Oct 8th, 2008, 4:20pm
Has anyone figured out a way to print pages with those math scripts in which the scripts actually appear on the page? (I'm using greasemonkey and the pages that print out don't include the scripts >.<)

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Oct 9th, 2008, 12:31am
One ad hoc way of doing it would be to paste together screenshots. Aside from that I have no ideas at the moment.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Oct 9th, 2008, 5:21am
Ooh, I just had that "Aha!" moment as to why they're not printing: in order to show up on the forums, the images we're using are white, and when you put them on a white background to print...

If you tell the browser to print background colors/images (file/Page Setup... in FF), you'll blow through ink/toner like it's free, but the symbols will show. :D

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Oct 9th, 2008, 6:18am
So another approach might be to save the page, batch invert the images, and then print; without wasting so much ink.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by KeyBlader01 on Oct 9th, 2008, 6:53am

on 10/09/08 at 06:18:26, towr wrote:
So another approach might be to save the page, batch invert the images, and then print; without wasting so much ink.


I know you gave me the zip file already but I'm curious, how would you do that? (How do you save the page and batch invert the images?)

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by Eigenray on Oct 9th, 2008, 7:05am

on 10/09/08 at 06:53:54, KeyBlader01 wrote:
I know you gave me the zip file already but I'm curious, how would you do that? (How do you save the page and batch invert the images?)

Save the page with your browser (choosing something like 'complete' rather than 'html only').  For Windows, [link=http://www.irfanview.com/]IrfanView[/link] is a good multi-purpose image viewer.  It can do batch conversions including image negation.  For Linux (or Cygwin), ImageMagick's convert is very useful too.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by Eigenray on Feb 6th, 2009, 1:31pm
The script breaks sometimes. It appears when I try to modify [link=http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=complex;action=display;num=1233771270;start=5#5]this post[/link] of mine, although it works again on preview.

Without understanding the code, I fixed it as follows:

Code:
@@ -438,11 +438,10 @@
if (match.index > begin) out += text.substring(begin, match.index);
begin = r.lastIndex;
out += '\\' + image;
-if (begin < text.length && (text.charAt(begin) == ' ' ||
-  this.lookupPrefix(image + text.substring(begin)).length > image.length))
-{
- out += " ";
-}
+if (begin < text.length) {
+ foo=this.lookupPrefix(image + text.substring(begin));
+ if(text.charAt(begin) == ' ' || (foo && foo.length > image.length)) out += " ";
+}

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Feb 9th, 2009, 6:36am
Version 1.4 (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js) -- the only change is a fix for the crashing bug Eigenray noted above.

(Eigenray, FYI, your patch addressed the symptom, but the real problem was in the lookupPrefix function itself: the word undefined needed quotes around it in lines 328 and 332.)

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by mathsman on Mar 30th, 2010, 12:56pm
I wish a video had been prepared

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by fizyka on Dec 30th, 2011, 3:33pm
Wouldnt it will be better just to use LaTeX ?
Or the new JavaScript library for that - MathJax ?

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Dec 31st, 2011, 7:27am
Unfortunately, either of those options would require modifying the forum server software, which only WIlliam can do, and he's a busy man.  In the mean time, this is the best solution we have.

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by cartoonle on Dec 19th, 2012, 1:37am
Hmmm....

Maybe he could send message string through a special made function, before the message is inserted in database. Function would only replace all occurrences of special characters with path to appropriate image representation of that character. That function wouldn't be hard to build .... only a list of "replace that with that". I would build it myself, if somebody provides me replace list.

Would that work?

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Dec 19th, 2012, 8:55am
Frankly, the forum is putting the server it's on under too much strain as it is without adding extra functions to its workload.
I think it's a much better idea just to upgrade to a new forum somewhere in the coming year and tackle a whole host of other problems in one fell swoop.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by cartoonle on Dec 20th, 2012, 2:54am
Yes, forum upgrade would be the most elegant solution. Although this new function wouldn't be to big problem, because it would trigger only when new post would be submited ... and that is not that often, or?
Well, it was just a thought.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by katakokok on Apr 15th, 2013, 10:21pm
I just know it. so I want to understand more about it. please guidance

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by imm0 on Jun 11th, 2013, 3:07am
why would a forum strain a server?

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Jun 11th, 2013, 9:14am

on 06/11/13 at 03:07:49, imm0 wrote:
why would a forum strain a server?
Because it's badly written software, and suffers from spammers.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by isha.lovie on Jan 9th, 2014, 6:47am
correct. need revision

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by sophiawright on Jul 18th, 2014, 12:29pm
I heard couple of days back but after reading all the best suggestions i understood clearly. thank you all
-Sophia

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Nov 24th, 2014, 1:18pm
Apparantly the forum/server has spontaneously switched to using https, and because of that the script's include parameter no longer matches.
You can edit the script and add
// @include https://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=*;*
(i.e. same line but with https iso http)
And then it works again (for me, in any case).

(Some other things remain broken though, because of mismatched protocols. Like the YABBC tag buttons and inserting smileys by clicking them)

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by rloginunix on Nov 24th, 2014, 6:34pm
towr's suggestion worked for me too: Firefox 16.0.1, Greasemonkey 1.10, wu::forums Math Symbol Support 1.4, OpenSuse 12.1 64-bit.

Thanks.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Mar 20th, 2015, 12:24pm
v1.5 Released: http://www.dwarfrune.com/smq/wu/wu_symbols.user.js

I've updated the Math Symbols script with the https fix towr mentions, and also added functionality to restore the YABBC tags and Smileys buttons.  I've only tested it under modern Firefox, but I expect it to work anywhere user scripts are supported.

I really should update the Howto at the top of this thread one of these years...

--SMQ

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by towr on Mar 20th, 2015, 1:16pm
Awesome, thanks.

Title: Re: [ FAQ : how to write (and view) math symbols ]
Post by SMQ on Sep 17th, 2018, 1:32pm
Updated to version 1.6: http://www.dwarfrune.com/smq/wu/wu_symbols.user.js

Uses http rather than https for the img tags, since at least for me using Tampermonkey on 64-bit Chrome it was broken.  Frankly I'm a bit surprised it still works at all more than a decade after I first wrote it! :)

--SMQ



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright 2000-2004 Yet another Bulletin Board