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

It seems MarkdownHere renders latex formula by google web api, which is inavaliable here in mainland China. Is there any other alternative options? #2

Closed
luohc2004 opened this issue Mar 4, 2020 · 5 comments

Comments

@luohc2004
Copy link

Since the option menu is not working under Zotero userinterface, if there exists one, how can I change that? may be by a config file?

@wtianyi
Copy link

wtianyi commented Oct 28, 2020

You are welcome to try my adaptation of markdown-here that uses KaTeX for HTML-only math equation rendering.

Please read the README.md and, especially, search for Zotero relate info there.

@luohc2004
Copy link
Author

luohc2004 commented Nov 4, 2020

You are welcome to try my adaptation of markdown-here that uses KaTeX for HTML-only math equation rendering.

Please read the README.md and, especially, search for Zotero relate info there.

Definitely I will try. That's great. I think maybe you can pull request to the main repo of Markdown-here~

@luohc2004
Copy link
Author

You are welcome to try my adaptation of markdown-here that uses KaTeX for HTML-only math equation rendering.

Please read the README.md and, especially, search for Zotero relate info there.

I referer to README.md and found that to user KaTeX for local equation rendering, I have to modify zotero's TinyMCE a little bit? Would it be a problem when zotero update itself ?

@wtianyi
Copy link

wtianyi commented Nov 4, 2020

Great! Let me know if you have trouble using it.

I thought about making a pull-request, but it seems that Markdown Here guys have thought through the possible options for changing the (obviously out-dated) math-rendering mechanism but decided CodeCogs is the way to go (see adam-p/markdown-here#144 (comment)). The reason is that KaTeX relies on special fonts to properly render, which is not generally feasible in rich-text editing scenarios (e.g. embedded equations in emails). Therefore, my adaptation deviates from the goal of Markdown Here and I think I might just leave the original repo as it is.

For the same reason, to make the KaTeX equations work properly in Zotero, one needs to hack the settings and resource files of the embedded TinyMCE editor in Zotero. You are right that this hack will not be able to survive an update of Zotero... Without the special fonts, the rendered formulas are still readable, just not so pretty...

On the other hand, I've tried to modify the Google charts API to CodeCogs. That modification would be as easy as a simple change of the default math-rendering API in 'math-value'. See

https://github.com/wtianyi/markdown-here/blob/f105982e8522eb27ab2fb03efc8b25de9d671e7d/src/common/options-store.js#L21-L22

and see https://github.com/wtianyi/markdown-here/blob/f105982e8522eb27ab2fb03efc8b25de9d671e7d/src/common/default.css#L204-L207 for a sample of accompanying CSS-style to make the rendered equations as high as a line and vertically better-positioned.

Note: You'll need to make this change based on the original Markdown Here repo, because I updated the marked.js library in my repo, and the math-rendering handling modifications in marked.js are lost, therefore my repo wouldn't work with the URL-API-based math-rendering.

@luohc2004
Copy link
Author

Great! Let me know if you have trouble using it.

I thought about making a pull-request, but it seems that Markdown Here guys have thought through the possible options for changing the (obviously out-dated) math-rendering mechanism but decided CodeCogs is the way to go (see adam-p/markdown-here#144 (comment)). The reason is that KaTeX relies on special fonts to properly render, which is not generally feasible in rich-text editing scenarios (e.g. embedded equations in emails). Therefore, my adaptation deviates from the goal of Markdown Here and I think I might just leave the original repo as it is.

For the same reason, to make the KaTeX equations work properly in Zotero, one needs to hack the settings and resource files of the embedded TinyMCE editor in Zotero. You are right that this hack will not be able to survive an update of Zotero... Without the special fonts, the rendered formulas are still readable, just not so pretty...

On the other hand, I've tried to modify the Google charts API to CodeCogs. That modification would be as easy as a simple change of the default math-rendering API in 'math-value'. See

https://github.com/wtianyi/markdown-here/blob/f105982e8522eb27ab2fb03efc8b25de9d671e7d/src/common/options-store.js#L21-L22

and see https://github.com/wtianyi/markdown-here/blob/f105982e8522eb27ab2fb03efc8b25de9d671e7d/src/common/default.css#L204-L207 for a sample of accompanying CSS-style to make the rendered equations as high as a line and vertically better-positioned.

Note: You'll need to make this change based on the original Markdown Here repo, because I updated the marked.js library in my repo, and the math-rendering handling modifications in marked.js are lost, therefore my repo wouldn't work with the URL-API-based math-rendering.

Thank you for your advice. I changed the value in options-store.js myself and learn a lot from you. Thanks a lot~

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

No branches or pull requests

2 participants