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

How do I use the Katex math renderer? #48

Closed
ajtaylor opened this issue Sep 22, 2018 · 4 comments
Closed

How do I use the Katex math renderer? #48

ajtaylor opened this issue Sep 22, 2018 · 4 comments
Labels

Comments

@ajtaylor
Copy link

Hi
I'm trying to use the Katex math renderer in my HyperMD editor, but I must be missing something.

I've imported the powerpack:

import * as katex from 'hypermd/powerpack/fold-math-with-katex';

and I'm instantiating my editor as follows:

          var editor = hyp.fromTextArea(el, {
            mode: {
              name: "hypermd",
              theme: "hypermd-light"
            },
            foldGutter: false,
            lineNumbers: false,
            hmdFold: {
              image: false,
              link: false,
              math: true
            },
            hmdHideToken: true,
            hmdCursorDebounce: true,
            hmdClick: true,
            hmdHover: true,
            hmdModeLoader: false
          });

If I then type

$\Gamma^2 = \Alpha^2+\Beta^2$

in my editor, I get the uppercase Gamma, but neither of the uppercase Alpha nor Beta.

How do I force the editor to use Katex rather than the default math renderer?

Thanks
Tony

@laobubu
Copy link
Owner

laobubu commented Sep 22, 2018

Hello. Just tested this code with Parcel and everything works well.

If you are using webpack, make sure that file-loader is configured properly so that KaTeX can load its font files (the files' suffix can be .woff, .woff2 or .ttf)

image

@ajtaylor
Copy link
Author

Thanks for the quick response.

I've added the webpack file-loader with a test for .woff, .woff2 and .ttf, but no luck.

The webpack build didn't error before I added the test for the font files, so I don't think it's trying to include any fonts.

Although I've got the import for the KaTeX powerpack, there is nowhere in my code where I actually reference it, so I'm guessing the build won't actually include it. Also, the webpack output doesn't show any fonts being included.

@laobubu
Copy link
Owner

laobubu commented Sep 22, 2018

Maybe webpack optimized and removed the imported powerpack because of no reference. Try:

-import * as katex from 'hypermd/powerpack/fold-math-with-katex';
+import 'hypermd/powerpack/fold-math-with-katex';

@ajtaylor
Copy link
Author

Yes, that worked!
Thank you very much for your (v quick) help, and also for HyperMD.

@laobubu laobubu closed this as completed Sep 22, 2018
ryooo pushed a commit to ryooo/HyperMD that referenced this issue Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants