wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> suggestions, help, and FAQ >> Math Symbols Redux
(Message started by: SMQ on Feb 7th, 2007, 12:50pm)

Title: Math Symbols Redux
Post by SMQ on Feb 7th, 2007, 12:50pm
I'd like to put a question to the community:

I'm working on bringing together the existing Firefox/Greasemonkey math symbol user scripts and adding a graphical entry interface to provide a single consistent math symbol entry and editing interface for those using Firefox with Greasemonkey; I'm wondering: what do you all feel would be the most convenient syntax for working with the symbols in the message edit box?  The leading contenders are:

1) The old [symbol] and [smiley=symbol.gif] syntax William added to YaBB before the upgrade.  Pros: simple, well understood, works similarly to existing posts and examples.  Cons: people who aren't aware of the old functionality tend to enter all kinds of things in square brackets without intending them to be math symbols, so there's a large potential for misinterpretation.

2) The new $symbol$ syntax used by towr's symbol entry script.  Pros: simple, relatively unambiguous.  Cons: "ugly" (IMO) especially when strung together, departs from past usage.

3) A more LaTeX-like syntax, perhaps even making an attempt to interpret $\sum_{n=0}^\infty$ as [sum]n=0[supinfty].  Pros: LaTeX syntax understood by most who would be using the text entry/editing functionality, compact, flexible.  Cons: more complex, departs from past usage, substantially more time to program and debug.

Once I have something put together and tested I'll post it to the math symbols FAQ where people might think to look for it. ;)

So what do you think?

--SMQ

Title: Re: Math Symbols Redux
Post by towr on Feb 7th, 2007, 1:06pm
Well, of course for 2) it is meant to depart from past usage. That way you avoid misconceptions about on which side it is handled; tags like [blah] are handled by the server, and tags like $blah$ have to be processed userside (and should never been visible serverside).
Of course option 3) would be preferable; but really, do you want to do that to yourself? ;)

Title: Re: Math Symbols Redux
Post by Icarus on Feb 7th, 2007, 2:19pm
Another problem with (3) is that you are not going to be able to implement a complete LaTeX syntax, or even close to it. This is going to cause LaTeX knowledgeable people consternation as they attempt things that won't work, resulting in an unfair dissatisfaction with what is already a fantastic application. It may be better just to implement (1) or (2) so as not to suggest more than you can deliver. (2) is ugly to look at, but is easier to read than the [smiley= ...] syntax, and I agree with towr that it is better to separate what the server does and what your tools do.


on 02/07/07 at 12:50:10, SMQ wrote:
Once I have something put together and tested I'll post it to the math symbols FAQ where people might think to look for it. ;)


I suggest starting a new FAQ thread. I've already been considering this, so you don't have 3 pages of no-longer-valid posts and schemes before coming to what works now. If you create a new thread, I'll make it sticky, and unstick the old one.

Title: Re: Math Symbols Redux
Post by towr on Feb 7th, 2007, 2:45pm

on 02/07/07 at 14:19:28, Icarus wrote:
Another problem with (3) is that you are not going to be able to implement a complete LaTeX syntax, or even close to it.
If he spends enough time and effort on it, he could. And certainly some subset of it. It's not such a complicated markup language anyway (a lot of command words, but very few command structures)

Title: Re: Math Symbols Redux
Post by Icarus on Feb 7th, 2007, 6:10pm
I was assuming that he is implementing this by means of the symbol gifs and the YaBB tags. That significantly limits what he can accomplish to something far less than a full LaTeX implementation.

Title: Re: Math Symbols Redux
Post by SMQ on Feb 8th, 2007, 5:41am
I see where the problem could be in providing an (apparently) arbitrarily limited subset of LaTeX layout functionality.  We do have available, however, a rich subset of LaTeX math symbols themselves, so what would you think of something like this:

- symbols are denoted by a leading backslash, e.g. "\pi" becomes "http://.../pi.gif" when posted
- non-alphanumeric LaTeX symbols are aliased so that they work, e.g. "\%" is equivalent to "\percent" (and, of course, "\sqrt" should be an alias for "\surd").
- for expository purposes, doubling the leading backslash denotes literal text rather than a symbol, e.g. "\\pi" becomes "\pi" when posted
- to avoid confusion when symbols are run against literal text, a single, optional trailing space will be consumed in the translation if present (and the graphical entry will always insert a trailing space), e.g. "\sqrt\pi" and "\sqrt \pi" are both equivalent, whereas "\sqrt  \pi" (two spaces) would place a space between the images, and "\frakca" is unambigously "http://.../frakca.gif" and not "http://.../frakc.gifa"

--SMQ


And incidentially, I've discovered another character sequence which generates the 500 error when attempting to post: ../ appearing anywhere in the posted text (!)

Title: Re: Math Symbols Redux
Post by Icarus on Feb 8th, 2007, 4:01pm
That might work. I also suggest introducing some sort of tag and restricting the translation to only that part of a post inside. Say [ math ] [ /math ]. You might not want to put it in square brackets, though: {math} {/math}.

This would mean that only those who are interested in posting mathematical symbols would. Someone who just wanted to put \a in their post for some reason wouldn't find it translated into http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/a.gif.

Title: Re: Math Symbols Redux
Post by SMQ on Feb 8th, 2007, 5:02pm
Well, that person might well not have the new greasemonkey script installed anyway, but yeah, some way to limit symbol expression by default sounds good.  I'm just thinking though, that certainly in my case at least, I most often use the symbol features for an isolated pi or sqrt here or there, not a concentrated block of symbology; and open and close tags would make that sort of quick one-off usage a bit more cumbersome...

What about a "include math symbols" checkbox underneath (like the "Notify of replies" and "Disable Smilies" checkboxes) which initially defaults off, but automatically becomes checked if any symbols are selected from the graphical interface (as opposed to just typed)?

--SMQ

Title: Re: Math Symbols Redux
Post by Icarus on Feb 8th, 2007, 5:15pm
That would work. Or you can just keep towr's Insert Symbols button. You only get math symbols if you press it.

One other suggestion: how about moving the graphics to the side of the text box instead of on top? One problem I'm having with the proto version is that the selection tables keep popping up on top of my text entry box when I am only trying to move the mouse by. Everytime it does, I have to move my mouse out of the selection area to get the table to go away again, then move my mouse back in from another direction.

It's a minor annoyance, but if symbols graphics were to the right of the text entry box, in particular, they would not be in a place where I move the mouse so often.

[ARRGH! I keep running into that select ... from problem, except I don't see any "from"s. There must be other keywords that also set it off when used with "select".]

Title: Re: Math Symbols Redux
Post by SMQ on Feb 8th, 2007, 6:01pm

on 02/08/07 at 17:15:48, Icarus wrote:
That would work. Or you can just keep towr's Insert Symbols button. You only get math symbols if you press it.

I thought about that, but I guess I'm trying to stick as close to the existing interface "paradigm" as I can, while keeping as much of the details behind the curtain as possible.  At least in my head the checkbox solution "feels" more "right"; but once I have a new prototype together we'll see how it really works out...


Quote:
One other suggestion: how about moving the graphics to the side of the text box instead of on top? One problem I'm having with the proto version is that the selection tables keep popping up on top of my text entry box when I am only trying to move the mouse by.

Yeah, I'm experiencing that frustration myself. :(  The problem is screen real estate; for someone running 800x600 there's no extra room to the right of the textarea...  what about moving the symbol "panes" that pop up above rather than below the "section" symbols?  I think there should consistently be room there no matter the screen layout, but they won't overlap the textarea on inadvertent cursor movement

--SMQ



Quote:
I don't see any "from"s. There must be other keywords that also set it off when used with "select".]


Quote:
then move my mouse back in from another direction.

[emphasis added] ;D

Title: Re: Math Symbols Redux
Post by towr on Feb 9th, 2007, 1:34am
Perhaps if you needed to click to get the symbol list, rather than just move the mouse over; i.e. more like a menu. That would avoid it popping up when you don't want it.

Title: Re: Math Symbols Redux
Post by Icarus on Feb 9th, 2007, 7:26pm

Quote:
then move my mouse back in from another direction.


Quote:
[emphasis added] ;D


:-[ I don't know how many times I read through that and failed to see that "from"!

Title: Re: Math Symbols Redux
Post by SMQ on Feb 14th, 2007, 2:17pm
OK, here is the first release candidate (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js) of the new all-in-one math symbol user script for Firefow with Greasemonkey.  Please uninstall any previous math symbol scripts (mine or towr's) before trying this one.

Usage is hopefully self-explanatory, just remember to check the "Insert Math Symbols" checkbox if you're not using the graphical entry UI.  Most of all, let me know what you think!  If it's well-received, I'll start a new Math Symbols using Firefox and Greasemonkey FAQ as per Icarus' suggestion above.

--SMQ

Title: Re: Math Symbols Redux
Post by towr on Feb 14th, 2007, 2:58pm
Seems to work nicely so far..

Title: Re: Math Symbols Redux
Post by SMQ on Feb 14th, 2007, 5:33pm
I've updated it with a minor bugfix for a problem where spacing between symbols wasn't preserved when previewing a post repeatedly.

For some fun, go to the first post in the 0.999... thread and click quote. ;)

--SMQ

Title: Re: Math Symbols Redux
Post by Icarus on Feb 14th, 2007, 6:05pm
Wow! That is cool. Makes me wish that post didn't suffer from the length restriction too, so I could redo it (of course, I've already wished that :P)

Maybe I ought to retire that 0.999... thread like I did the first and start over...

Title: Re: Math Symbols Redux
Post by TenaliRaman on Feb 14th, 2007, 8:34pm
http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbf.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbi.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbn.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bba.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbl.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbl.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bby.gif!!

-- http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bba.gifhttp://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/bbi.gif

Title: Re: Math Symbols Redux
Post by THUDandBLUNDER on Feb 15th, 2007, 8:08am
That's great, SMQ! Thanks for all your hard work!  

Title: Re: Math Symbols Redux
Post by SMQ on Feb 15th, 2007, 12:58pm
Release Candidate 2 (http://www.dwarfrune.com/~smq/wu/wu_symbols.user.js)

No functionality changes, but now tested and working under Internet Explorer 6 and above using Turnabout (http://www.reifysoft.com/turnabout.php); and under Opera 8 and above using the build-in User Script functionality (and of course Firefox 1.5 and above using Greasemonkey (http://greasemonkey.mozdev.org)).  I think it should work under Safari using Creammonkey (http://creammonkey.sourceforge.net/) as well, but I don't have a Mac available to test it on...

--SMQ

Title: Re: Math Symbols Redux
Post by towr on Feb 15th, 2007, 2:56pm
One small detail, which isn't relevant unless someone else runs script that may conflict with it; when you add/change eventlisteners, you might check if there already aren't ones, and if there are also run those (before or after the code of your own eventlistener).

And also, after having finally looked at the code a bit, WOW! :o

Title: Re: Math Symbols Redux
Post by SMQ on Feb 15th, 2007, 4:06pm
The addEventListener function already takes care of handling multiple listeners for you -- that's one of the reasons it was created (as opposed to the simpler object.onevent = function syntax).  I believe IE's attachEvent works the same way.

As for the rest of the code, the two data tables and the regular expressions do all the heavy lifting; the rest of it's pretty much simple string manipulations, fairly straightforward (and ugly) HTML generation, and a few fairly standard (as much as the term even applies to cross-browser web programming) mouse event handlers to drive the "menu".  I even threw in some comments for good measure.  Still, thanks. ;)

--SMQ



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