tth05 / obsidian-completr

Auto-completion plugin for the obsidian editor.
MIT License
291 stars 18 forks source link

Better LaTeX Environment Detection #15

Closed zcysxy closed 2 years ago

zcysxy commented 2 years ago

Thanks for this plugin! I really rely on it to write math in Obsidian. I'm thinking is it possible to improve the detection of the LaTeX environment? Currently the LaTeX provider will be triggered after any dollar sign, even in code blocks. So I think the better logic is to ignore dollar signs in inline code, code fences, and escaped dollar signs \$.

tth05 commented 2 years ago

Thanks, that's probably a good idea. I'll get back to working on this this weekend. If understand correctly, you're talking about ` and ```, right?

zcysxy commented 2 years ago

Thanks, that's probably a good idea. I'll get back to working on this this weekend. If understand correctly, you're talking about ` and ```, right?

Yes! And also the escaped dollar signs \$. For example, the dollar sign in It costs me 15\$. should not trigger the LaTeX provider.

tth05 commented 2 years ago

Implemented in 45e9bf8de49a0b20b60e9b2898a407a9a512efde. I made as an option because one might need this when writing admonition blocks or something similar. Let me know if it works how you'd expect it to work.

zcysxy commented 2 years ago

Yeah it works as expected. Thanks a lot!

fmbarina commented 2 years ago

Hi, sorry if reviving an issue like this is considered inappropriate, I just wanted to add another possible enhancement.

LaTeX completion becomes enabled for the entire file if you use $$ (double dollar signs) in the document front matter, as a value, for example. I don't think makes much sense? The rest of obsidian doesn't seem to think the entire document is LaTeX, so maybe Completr should follow that convention as well.

Idea: add another option to ignore LaTeX completion trigger if inside front matter

Q: That's a very weird case, how did you stumble upon that? A: I have a field called cost and wanted to use $, $$, or $$$ to indicate cost, so this is probably a very rare and maybe even unimportant issue.

tth05 commented 2 years ago

Very rare use-case indeed, but should be fixed now!

fmbarina commented 2 years ago

Hi, that is some fast development!

Thank you for taking such a rare case so seriously. I'm afraid LaTeX completion is completely broken for me now? Coding is Fun. Maybe it's something I did, but after updating, I can't trigger LaTeX completion. To be clear, this also happens without the front matter block. I checked the manifest, and it says "version": "2.8.1". I also checked the settings, and completion is on, just as it was before.

(no "begin" suggested) image

If you think this should be a separate issue or that there's anything I can do to help, just say the word.

tth05 commented 2 years ago

Sorry, I did this in a hurry and messed up. Fix is out :)

fmbarina commented 2 years ago

No need to apologize, thanks a lot! Fix works fine.