Skip to content
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

Add equation syntax #314

Open
mathisonian opened this issue May 14, 2018 · 7 comments
Open

Add equation syntax #314

mathisonian opened this issue May 14, 2018 · 7 comments

Comments

@mathisonian
Copy link
Member

It would be great to write $...$ or $$...$$ instead of [equation]...[/equation] [equation display:true]...[/equation]

@hemu
Copy link
Contributor

hemu commented Oct 14, 2018

Don't know enough about lexing + parsing to understand what is considered the cleaner approach / best practice. Let's say we have both of these inputs:

[Equation]
  y = \int x^2 dx
[/Equation]
$$
  y = \int x^2 dx
$$

Is it better practice to:

  1. Handle this at lexer level, i.e. in lexer.js so that they both output identical tokens and are indistinguishable for parser.
  2. Handle this at parser level. So maybe lexer converts "$$" into some new token, let's say EQUATION, that we handle with equation token specific definition in grammar.ne, kind of like how there are currently defintions for ImageInline and LinkInline, so that the final ast is indistinguishable for both.
  3. Handle at some other level I don't know about

@mathisonian
Copy link
Member Author

mathisonian commented Nov 8, 2018

@hemu it would be best to add an additional rule in the lexer, similar for how we special case equation tags here: https://github.com/idyll-lang/idyll/blob/master/packages/idyll-compiler/src/lexer.js#L53-L66.

The regex is a little hairy, but the same logic should be applicable to the new $$ tokens.

@michaltakac
Copy link

michaltakac commented Jul 30, 2019

@mathisonian I've started working on this here #573, tests pass but so far haven't succeeded in testing this manually inside new idyll project/document - adding $$y=0$$ somewhere in text does nothing.

Edit: found the problem, it was regex.

@michaltakac
Copy link

Wouldn't [$...$] and [$$...$$] be better instead of $...$ and $$...$$? That way it works beautifully :) but it's just me battling with the regex :D.

Inline equation [$ y = x^{\frac{\pi}{2}} $], or centered: [$$ y = 0 $$]

Or with some whitespaces for nicer formatting:

[$$
  y = \int x^2 dx
$$]

Screen Shot 2019-07-30 at 14 37 27

@mathisonian
Copy link
Member Author

Thanks for the work on this @michaltakac! Also saw your comment on #314, I think that would be awesome to add - we should discuss syntax for that as well. I'm totally in favor of getting changes in to improve the equation/latex experience, but it will probably will be a couple days before I can do a close review.

Edit: found the problem, it was regex.

A tale as old as time.

Arguments for [$$...$$] vs [$$]... [/$$] to keep things more consistent with the existing syntax?

@michaltakac
Copy link

Feeling that [$]...[/$] and [$$]...[/$$] would suit Idyll better - basically it would be a syntactic sugar for [equation /].

@suhr
Copy link

suhr commented Aug 3, 2019

[$ $] is easier to type than [$][/$]. Both are surely better than $ $, because it won't accidentally parse something as an equation.

Note that there's also other latex syntax: \( \) for inline equations and \[ \] for block equations.

@mathisonian mathisonian pinned this issue Aug 13, 2019
@RakeshUP RakeshUP mentioned this issue Jan 3, 2020
2 tasks
@mathisonian mathisonian unpinned this issue May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants