ethan-ou / vscode-gift-pack

VSCode Language Pack for Moodle's GIFT Language
https://ethan-ou.github.io/vscode-gift-docs/
MIT License
4 stars 0 forks source link

Support for Additional Latex Package Chemfig. #1

Closed ajeducation closed 3 years ago

ajeducation commented 3 years ago

We use LATEX package 'Chemfig' to add Organic Chemistry Structures in Moodle. Is there a way to add additional LATEX package so that output can be viewed in preview window?

ethan-ou commented 3 years ago

To display LaTeX I'm using a package called KaTeX. They've opened an issue to talk about how to port chemfig but apparently it's a pretty complex problem and no substantial progress has been made. If you're ever up for a challenge, you can try to give it a shot!

The other thing you can try is injecting SVG directly into the GIFT question. Once you've written something in chemfig, take the SVG output (should look like HTML) and copy it over to your question. Make sure you also escape everything so that it displays properly in GIFT. You can do this quickly by selecting the SVG text, then right clicking and going to Refactor > Escape Text.

ajeducation commented 3 years ago

I had earlier tried placing SVG in html editors of Moodle, but that did not work. Additionally SVG is not neat because it contain larger code than chemfig. I have enabled chemfig in Moodle and it works fine. In our academic college, I will teach the teachers about Moodle GIFT format. I will use your VSCode-gift pack for same, Its snippets and preview mode is really useful for new learners. I understand from you that there is no easy solution to preview chemfig in VSCode-gift-pack, so its ok if chemfig can not be previewed.
mhchem is another extension for chemistry in LaTeX and KaTeX non-natively support it . How mhchem can be enabled in VSCode-gift-pack?

ethan-ou commented 3 years ago

mhchem definitely looks doable. Let me open this back up and I'll give it a shot at integrating it.

ethan-ou commented 3 years ago

mhchem is working perfectly. The update should go live as soon as you read this.

image

ajeducation commented 3 years ago

Thanks for mhchem update. Is it possible to implement LaTeX support without escaping curly brackets. In LaTeX and Moodle, curly brackets will be used as such without escape character. Meanwhile workaround will be to to find and replace escaped brackets and then import into Moodle.

ethan-ou commented 3 years ago

Are you sure this is the case with LaTeX in GIFT? Would you be able to show me what happens when escaped vs unescaped GIFT questions are uploaded to Moodle?

ajeducation commented 3 years ago

You are right. In Moodle, While uploading from GIFT format, reserve characters need to be escaped, while writing directly on Moodle interface, reserve characters are not escaped.

ethan-ou commented 3 years ago

Good to hear! I'll close this for now. Let me know if you find any solutions for implementing chemfig with KaTeX and we'll open it back up.