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

Should move from raw HTML to MathJax for embedded math #479

Closed
JacquesCarette opened this issue Mar 23, 2018 · 37 comments · Fixed by #1832
Closed

Should move from raw HTML to MathJax for embedded math #479

JacquesCarette opened this issue Mar 23, 2018 · 37 comments · Fixed by #1832
Assignees

Comments

@JacquesCarette
Copy link
Owner

See #478 for most of the discussion on this topic.

@JacquesCarette
Copy link
Owner Author

Put in as low priority, as the current HTML is ok.

@JacquesCarette
Copy link
Owner Author

We'd already discussed this in #300. And should keep #412 in mind too.

@JacquesCarette
Copy link
Owner Author

@danscime can you check that all of the examples use MathJax as the default? If so, then close this issue.

@danscime
Copy link
Collaborator

All 6 examples have this line in the HTML files.

Screen Shot 2019-05-21 at 8 35 36 AM

@JacquesCarette
Copy link
Owner Author

That doesn't mean it uses it, unfortunately! We added that to all examples very early, as it is relatively harmless to do so. You have to look both inside the html file to find some latex, and look in the example's configuration settings to make sure it uses the MathJax option.

@danscime
Copy link
Collaborator

I did a search through the files. No use in any files for \, $, or $$ which seem to be most commonly used characters for MathJax.

And for the config settings, the .css files did not have anything resembling or mentioning Latex or MathJax.

@JacquesCarette
Copy link
Owner Author

Right, so this is not fixed at all. I guess it will make sense to do this after the current pass on indenting is done. Re-assigning.

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

As a test (on Tiny).

Before:
Screen Shot 2019-06-06 at 9 15 10 AM

Changing one equation to use Latex symbols:
Screen Shot 2019-06-06 at 9 15 53 AM

Changes from 9d537ce

@smiths
Copy link
Collaborator

smiths commented Jun 6, 2019

The second version of the table definitely looks nicer than the first. Great!

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

Adding displayed equations.

Before (Using original without any MathJax):
Screen Shot 2019-06-06 at 9 59 21 AM

After adding displayMath option:
Screen Shot 2019-06-06 at 9 59 33 AM

Changes from 3213be8

@smiths
Copy link
Collaborator

smiths commented Jun 6, 2019

I like the fonts for the second example better, but the left justification (from the first example) looks better than the centre justification in the second (in my opinion). How hard would it be to left justify the second case? (This is a minor request; I wouldn't want to block progress for such a simple formatting suggestion.)

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

Left justified / inline:
Screen Shot 2019-06-06 at 9 59 33 AM

Left justified makes the font smaller not sure exactly why. But from what I know so far, equations can be inline with surrounding text or displayed to be a separate entity.

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

The tex also has this equation displayed / centered.
Screen Shot 2019-06-06 at 10 12 16 AM

@smiths
Copy link
Collaborator

smiths commented Jun 6, 2019

It isn't a big deal, but one looks in-line in tex with $ $. While the other looks like a full equation, using $$ $$.

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

You're right, source code for the Tex displays the Units part inline and equation part as displayed.

I feel like the end goal would be to use whatever prints the math in Tex to be used for HTML, so the HTML would follow whatever Tex does in terms of which parts are inline vs. displayed.

So I think I should base the HTML off of the Tex for now. And then once automated, we can change the formatting if we decide to.

@smiths
Copy link
Collaborator

smiths commented Jun 6, 2019

Sounds like a good plan. 😄

@danscime
Copy link
Collaborator

danscime commented Jun 6, 2019

Tiny stable fully updated via c95cdf0

@danscime
Copy link
Collaborator

As of 76418b9, I believe I have made all necessary changes on my beginMathJax branch in order to have expressions and units display as embedded Latex.

These cause significant changes to the HTML files. So I will go through the stable changes.

@smiths @JacquesCarette what should be the workflow?
Should I check through each diff to make sure nothing unexpected has occurred? And just cautiously make my way through each example?

@JacquesCarette
Copy link
Owner Author

See my comments on the commits on that branch. But that won't actually affect the HTML files themselves.

Yes, you'll have to go through them carefully. Start with the smaller ones - if there's something weird, it's likely pervasive and will already show up there. You can also turn on MathJax example-by-example (right?), so that these can be incorporated into stable incrementally.

@danscime
Copy link
Collaborator

@JacquesCarette currently, the way it is set up, it affects all examples. If in the future, we want to have the ability to switch, then I could look into it. But if the end goal is to only have MathJax (which it seems like it should be), then it may not be worth looking into. In this case, there will be a big PR with many merges to master.

So far I am almost done Projectile and have not noticed anything unexpected.

@JacquesCarette
Copy link
Owner Author

I had asked Devi to have an option for that, which he did implement, to funnel that option around.

@danscime
Copy link
Collaborator

@JacquesCarette I am not sure where this is.

I have changed the actual functions in HTML/Print.hs. I would probably need to keep the original functions and create new functions with mathJax abilities, and then this option would choose which functions to use I suppose.

@JacquesCarette
Copy link
Owner Author

It was in a branch of his. It might have gotten deleted, I'm not sure.

I don't think there's a need for copying anything. Yes, the original functions will need to be kept, and then the option would choose which ones to call.

@danscime
Copy link
Collaborator

@JacquesCarette I will look to try to find something he may have created.

@danscime
Copy link
Collaborator

danscime commented Aug 6, 2019

Currently, I have updated Projectile HTML. Mathjax right now is only being used for:

  • displayed math equations
  • fractions
  • square roots
  • matrices
  • cases

These changes can be found in this compare.

@JacquesCarette
Copy link
Owner Author

We might eventually want to have fractions in mathjax too - but otherwise, this looks good.

@danscime
Copy link
Collaborator

danscime commented Aug 9, 2019 via email

@JacquesCarette
Copy link
Owner Author

I saw some fractions in HTML. Maybe just for units? Which I think is fine.

@danscime
Copy link
Collaborator

danscime commented Aug 9, 2019 via email

@danscime
Copy link
Collaborator

One minor issue, should be a trivial fix.

In some equations, a less than symbol < with a letter beside it seems to make the HTML think it is starting a tag.
Screen Shot 2019-08-12 at 9 55 11 AM

Renders this:
Screen Shot 2019-08-12 at 9 55 36 AM

@JacquesCarette
Copy link
Owner Author

We need to figure out how to "properly" embed latex in html. My guess is that the easiest way to do that is to always use \lt (and \leq and ...) in the latex instead of ever putting out a < or even a >.

@smiths
Copy link
Collaborator

smiths commented Aug 12, 2019

@danscime, I did a bit of googling on this. Can you define new commands for \lt and \gt in the generated tex files?

https://tex.stackexchange.com/questions/12519/what-library-do-i-have-to-use-such-that-the-document-can-render-lt-and-gt-as-l

@danscime
Copy link
Collaborator

@smiths that seems to work! I will begin to implement.

@JacquesCarette
Copy link
Owner Author

Note that the proper macros should be

\newcommand{\lt}{\ensuremath <}
\newcommand{\gt}{\ensuremath >}

@JacquesCarette
Copy link
Owner Author

And \leq and \geq already work as is, so not need to define those.

@JacquesCarette
Copy link
Owner Author

I note that the mathjax documentation http://docs.mathjax.org/en/latest/tex.html says we should use \(...\) for inline math (rather than $...$) and \[..\] for displayed (rather than $$...$$).

Further down that same page, it has advice regarding < and > .

@danscime
Copy link
Collaborator

I will make these changes.

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.

3 participants