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

Remove hacky $ concatenation in HTML Print #1780

Open
danscime opened this issue Jul 31, 2019 · 9 comments
Open

Remove hacky $ concatenation in HTML Print #1780

danscime opened this issue Jul 31, 2019 · 9 comments
Labels
needs-clarification Needs a clear 'state', 'goal', 'analysis', and 'explanation' to reduce solution ambiguities.

Comments

@danscime
Copy link
Collaborator

Based on comments in: ac99c9d

@JacquesCarette
Copy link
Owner

You should 'dispatch' to the routines of the other printer differently and directly. In particular the BlockEqn shouldn't call the HTML pExpr but rather the latex one.

Also, based on other comments, I think we don't quite want to go 100% MathJax. I think we want to print the simple stuff still in HTML, and only the complex stuff in latex.

Easiest way to do that would be to change the current HTML pExpr to return an Either Doc Doc. If it's a Left (say), we know it only contains plain HTML, so can be used as is; if it's a Right, it's still HTML, but with 'hacks', so that we'd rather go with MathJax in that case.

@danscime
Copy link
Collaborator Author

The biggest hurdle seems to be the type mismatches between the HTML and Tex Print files.

Screen Shot 2019-07-31 at 11 35 22 AM

Screen Shot 2019-07-31 at 11 35 52 AM

I can not do a straightforward call to the Tex functions.

As for the Either Doc Doc, how do we want to decide what is a hack, and what is not?

@JacquesCarette
Copy link
Owner

Yep, you will need a PrintingInformation structure to be able to go between them. But that's how options are passed, so that's going to be needed long-term anyways.

The decision as to what is a hack or not is fully subjective. I would say that any kind of 2-dimensional printing (fractions, integrals) are a hack. We can review things further, and move items between the two categories easily if we have this infrastructure in place.

@danscime
Copy link
Collaborator Author

Related to #479

@danscime
Copy link
Collaborator Author

I'm still unsure of where to go from here. I can add the PrintingInformation parameters, but then how should be translating to or from D and Doc.

Currently I have a function that goes from D to Doc. But I don't know exactly how we want things to be done.

Screen Shot 2019-07-31 at 4 19 13 PM

@danscime
Copy link
Collaborator Author

danscime commented Aug 1, 2019

@samm82 and I were discussing. It seems like the Latex print uses a D type to stage the math for printing. HTML should also use this as it would need to stage the math.

So the HTML file may need to undergo some renovations in which the functions pass through PrintingInformation as well as outputting D types instead of Doc types.

Not sure how or where to start.

@Mornix
Copy link
Collaborator

Mornix commented Aug 1, 2019

Correct me if I'm wrong, but that seems like an incorrect approach. D is very much a LaTeX specific "thing" specifically designed to abstract away the mode switching. Wouldn't a more appropriate solution to be:

printMath d = runPrint d Text?
If the printed text is just text, then no $ should be generated, where as if it is truly math then the mode should be set (within D to Math and the $ generated.

@danscime
Copy link
Collaborator Author

danscime commented Aug 1, 2019

@Mornix That definitely may be the key to this issue! Will continue to work with this.

@JacquesCarette
Copy link
Owner

Note that, in this instance, we know more: when we encounter a BlockEqn while printing HTML, we know we're going to be in Math mode. Nevertheless, as @Mornix says, passing the whole BlockEqn directly to the latex printer (not just its contents) should in fact take care of adding the $$. The same analysis needs to happen in the 'other' case (Expr ?). But yeah, letting the latex printer figure it out, as it already has the mode logic built-in, is probably the thing to do.

@JacquesCarette JacquesCarette mentioned this issue May 14, 2020
2 tasks
@balacij balacij added the needs-clarification Needs a clear 'state', 'goal', 'analysis', and 'explanation' to reduce solution ambiguities. label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-clarification Needs a clear 'state', 'goal', 'analysis', and 'explanation' to reduce solution ambiguities.
Projects
None yet
Development

No branches or pull requests

5 participants