-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align #60
base: matrix
Are you sure you want to change the base?
Align #60
Conversation
…trix. This lets the user cross over the top or bottom of the matrix naturally without getting caught inside it, using the same config option as for fractions.
By overriding moveTowards and moveOutOf on matrix and MatrixCell respectively, we can avoid changing {up,down}Into into functions and so keep these changes restricted to affecting the matrix environment.
Hi @eoghanmcilwaine! I've merged master into this and added a unit test and visual test. This is the visual test output: However, it's not quite right yet - I'd really like it to respond to click events by placing the cursor in the near row. At the moment, it appears to put the cursor in the top row if you miss. I was wondering if you have any idea how to accomplish that in MathQuill? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alexf101, nice work here.
To answer your question - the cursor positioning after a click is set by the seek controller method. It basically puts the cursor inside/beside the math object you've clicked.
Because the =
s down the middle are just some extra html inserted into the {align*} table rather than being math objects in their own right, all seek
knows is that you've clicked somewhere on the {align*} object. So the cursor is inserted at the top of the table somewhere.
I think the solution would probably be to allow mathquill to parse and insert the =
s as normal (well not exactly as normal because it'd be great to keep the extra <td>
around the = somehow).
Incidentally this could help reduce the divergence between Matrix and Align* as the column delimiter would no longer be different. I'm just doing a review of your code - it's a good solution in general but one thing I'm not sure about is adding Align-specific conditional stuff to Matrix (it's like this classic code smell). There's probably a neater way. I'm having a go at using a common abstract ancestor for Align and Matrix but there could be a slicker way.
src/commands/math/commands.js
Outdated
@@ -863,7 +863,7 @@ LatexCmds.begin = P(MathCommand, function(_, super_) { | |||
var string = Parser.string; | |||
var regex = Parser.regex; | |||
return string('{') | |||
.then(regex(/^[a-z]+/i)) | |||
.then(regex(/^[a-z*]+/i)) // LaTex uses * as a convention for alternative forms of a command, usually 'without automatic numbering' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @alexf101, am I right in saying the asterisk can only come at the end? So it'd be something like ^[a-z]+\*?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable - I'm no latex expert, but I've only ever seen it used at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eoghanmcilwaine can you give me the mathquill.js and mathquill.css . I can't build
error message:
' undefinedError: Cannot read property 'eval' of null '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eoghanmcilwaine thank you very much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eoghanmcilwaine matrix . my email: [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/commands/math/commands.js
Outdated
// differently in latex. Nevertheless, we want it to render as a table so it's convenient to extend Matrix. | ||
Environments['align*'] = P(Matrix, function (_, super_) { | ||
_.environment = 'align*'; | ||
_.extraTableClasses = 'rcl'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexf101 I think all mathquill classes start with mq-
so best to stick with that convention here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
test/visual.html
Outdated
\begin{align*} | ||
y &= mx+c \\ | ||
y-c &= mx \\ | ||
\frac{y-c}{m} &= x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we encode the ampersands as &
? Just so it's really unambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
- Tighten regex to only allow * at the end - prefix mathquill class names with 'mq-' - Use '&' in HTML files instead of & for literal ampersand.
Ok, thanks so much for that information! So the mental model I have is that the nearest parent object of any cell in the Would it make sense (and solve the problem of click events on It seems like a fairly deep reimplementation would be required to introduce a MatrixRow to the object - I would view this as a practical reason to follow your advice and separate the align environment from the matrix implementation, even if most of the code ends up being similar. I'll try and have a crack at it - let me know if this approach makes sense to you, or something else :) |
Cheers @alexf101. I think you're spot on about rows making more sense as separate objects. It's a pretty big change though. I came up with a solution to the cursor-in-top-row issue without changing By the way, I separated the matrix and align logic in another commit. |
@eoghanmcilwaine Looks awesome! Let's move to the align-alternative branch :) Is there a PR for merging align-alternative into MathQuill that I can jump on? So sorry about the long delay - the usual story of too aggressive email filters on GitHub notifications, working on other projects, etc. I really appreciate the interest you've taken in this! |
@eoghanmcilwaine I tried it out, and it seems to... kind of work? I have to click pretty precisely on the middle of the equals sign for it to stay in the same row. Is that your experience too, or did I make some mistakes merging your branch over our fork? |
Support align* environments for displaying and editing multi-line equations.
To get this working with a minimum of code duplication, I've massaged the matrix environment slightly to have certain parameters configurable that were previously not. In particular, there's now an htmlColumnSeparator for adding non-editable visual content to separate the columns, which in this case is the ' = ' sign.
Customary GIF :)

Requires: