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

convertDeltaToHtml wont work when there is a formula #1

Open
haojia321 opened this issue Aug 22, 2018 · 7 comments
Open

convertDeltaToHtml wont work when there is a formula #1

haojia321 opened this issue Aug 22, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@haojia321
Copy link

Hi
If the delta has a formula, the convertDeltaToHtml wont work.

var deltaWithFormulaExample = { "ops": [{ "insert": { formula: "$$\small{4 \div 0.25 \ =}$$ _____ $$\small{\times 4}$$" } }] };

@joelcolucci
Copy link
Owner

Hi @haojia321 . Thank you for submitting this. I'll take a look at this later today.

@joelcolucci joelcolucci self-assigned this Aug 23, 2018
@joelcolucci
Copy link
Owner

@haojia321 Thank you for your patience.

Background
Quill requires an additional package (KaTeX) to be loaded into the browser in order to render formulas. KaTeX converts the TeX/LaTeX markup to HTML/CSS.

Issue
Currently node-quill-converter does not load KaTeX into the JSDOM instance. Therefore formulas do not render into HTML. This is likely what you are experiencing.

Possible solution(s)
I can open up a new issue as an enhancement request and look at adding an option to import the KaTeX library.

@joelcolucci joelcolucci added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Aug 23, 2018
@haojia321
Copy link
Author

@joelcolucci Thank you for your response. You are right, this is exactly the issue we are facing now. Just wondering when will this be fixed?

@joelcolucci
Copy link
Owner

@haojia321 I will take a look today/tomorrow at extending the API to import KaTex. I'll keep you updated.

@joelcolucci
Copy link
Owner

@haojia321 Can you provide an example of correct input and expected output?

Below is the current test case I'm using. The output includes a KaTeX error. I'm working to confirm if this is due to a bad Delta, code, or test framework.

Input

let deltaWithKatex = { ops: [{ insert: { formula: "$$\small{4 \div 0.25 \ =}$$ _____ $$\small{\times 4}$$" } }] };

Output

<p>
<span class=\"ql-formula\" data-value=\"$$small{4 div 0.25  =}$$ _____ $$small{       imes 4}$$\">
  <span contenteditable=\"false\">
    <span class=\"katex-error\" title=\"ParseError: KaTeX parse error: Can't use function '$' in math mode at position 1: $̲$small{4 div 0.…\" style=\"color:#f00\">$$small{4 div 0.25  =}$$ _____ $$small{  imes 4}$$</span>
    </span>
</span>
</p>

@haojia321
Copy link
Author

Hi @joelcolucci ,
Sorry I gave invalid data in my previous comment. Below 2 are valid deltaWithKatex;

let deltaWithKatex = { ops: [{ insert: { formula: "\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }" } }] };

let deltaWithKatex = { ops: [{ insert: { formula: "e=mc^2" } }] };

@joelcolucci
Copy link
Owner

@haojia321 Thanks. I'm continuing to work on this. There are inconsistencies in the output at the moment. I'll keep you updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants