wei2912 / obsidian-latex

MIT License
146 stars 21 forks source link

Fix LivePreview #17

Closed MinusGix closed 2 years ago

MinusGix commented 2 years ago

This fixes LivePreview support and makes the plugin work (fixing #16 ).
I had to update to minimum version 0.12.16, in order to have the loadMathJax function. It appears that in the new editor, registerMarkdownPostProcessor never gets called, which is really weird.
Finding information about what changes might be needed for live-preview was rather hard, and several of the other extensions that I looked at which added live-preview support weren't using the reigsterMarkdownPostProcessor and so didn't shed any light on that.
However, since the 0.12.16 version of the API added a loadMathJax function, it lets us load MathJax in the onload of the plugin. Then we can simply do the same modification as it had done before.
Though, I'm uncertain if it is exactly the same. \def and \newcommand appear to apply globally with the modification of the plugin, but it might not be 100% equivalent to how it worked before? I'm uncertain, but the testing page works.
I also had to change the read preamble function to use a different read function since I was getting a return value of null when trying to read the file.

xldenis commented 2 years ago

Thanks!

xldenis commented 2 years ago

I'll make a release later today

joethei commented 2 years ago

@xldenis Currently, the plugin cannot be installed at all because the version 3.0 does not exists as a release yet. Obsidian always tries to install the version that is in the manifest.json first(which is 3.0 curently).

xldenis commented 2 years ago

Ah I forgot about that, I'm going to put releases on a separate branch and fix this issue right now.

xldenis commented 2 years ago

@joethei just confirmed I was able to update my install, I should really get in the habit of updating things more often...

joethei commented 2 years ago

can confirm installing works, thank you for the quick response