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

feat: add mhchem katex extension #678

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Jhsmit
Copy link
Contributor

@Jhsmit Jhsmit commented Jun 10, 2024

mhchem package provides commands for typesetting chemical molecular formulae and equations

mhchem katex extension docs are here

this contribution is a combination of copy-paste with suggestions from codeium

example:

import solara

md_text = """
Normal math:

$$
1 + 1 = \sqrt{2}
$$

mhchem:

$$
\ce{6CO2 + 6H2O -> C6H12O6 + 6O2}
$$

"""

@solara.component
def Page():
    solara.Markdown(md_text)

output:
image

mhchem package provides commands for typesetting chemical molecular formulae and equations
@@ -157,6 +158,11 @@ def _markdown_template(
async loadMermaid() {
return (await this.import([`${this.getCdn()}/mermaid@10.8.0/dist/mermaid.min.js`]))[0]
},
async loadMHchem() {
await this.loadKatex();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await this.loadKatex();
await this.loadKatex();
Suggested change
await this.loadKatex();

This will cause the CSS to be added twice,

@@ -92,6 +92,7 @@ def _markdown_template(
await this.loadRequire();
this.mermaid = await this.loadMermaid();
this.mermaid.init();
await this.loadMHchem();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to move that to after line 110, if/when we use katex.

@Jhsmit
Copy link
Contributor Author

Jhsmit commented Jul 8, 2024

I've now added the loading of mhchem to the same this.import call which loads katex. It seems like the better solution.

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

Successfully merging this pull request may close these issues.

2 participants