vscode-latex-basics icon indicating copy to clipboard operation
vscode-latex-basics copied to clipboard

Support macro `\cacheMeCode` from robust-externalize

Open jlelong opened this issue 1 year ago • 2 comments

This is a follow-up on #79 #77.

This PR adds support for \cacheMeCode[options]{code}. Both the content of [] and {} can span over several lines.

@dflvunoooooo @tobiasBora Currently the code part is considered as verbatim. Would it make sense to support embedded language and if so how can it be inferred from the optional argument?

jlelong avatar Mar 28 '24 17:03 jlelong

Thanks a lot! So a few remarks:

  • I use the convention that environments start with upper case letter and command with lower case letters,
  • \CacheMe (or rather \cacheMe) is morally the command version of \begin{CacheMe}, that we decided to keep in LaTeX form as it actually parses the code as LaTeX (removing %…), so I guess it would make sense to do the same for \cacheMe
  • \cacheMeCode[preset options]{code} is indeed the equivalent of \begin{CacheMeCode}{preset options}code\end{CacheMeCode} (or rather will, I wrote it recently and I'll push it soonish once I finish working on a nicer way to work with python & sagemath). But the idea is exactly the same : you can parse the language exactly like in CacheMeCode to print it accordingly.

tobiasBora avatar Mar 28 '24 20:03 tobiasBora

Thanks for the explanations. I fixed the macro name to only consider \cacheMeCode. As for the CacheMe environment, the standard LaTeX grammar can already handle the macro \cacheMe.

I will add the recognition of embedded languages for \cacheMeCode.

jlelong avatar Mar 29 '24 08:03 jlelong

@tobiasBora I hope to be back on track to finalize this PR.

If you have time, could you test this new grammar? Embedded languages should now be properly recognized inside the \cacheMeCode macro.

jlelong avatar Mar 17 '25 09:03 jlelong

@tobiasBora By any chance, could you test this PR before I merge it.

jlelong avatar Mar 22 '25 15:03 jlelong

I don't use vscode and I can't access my laptop now, so it might be hard for me to test but the user that requested this feature originally may have more luck? @dflvunoooooo

But thanks for the great work!

tobiasBora avatar Mar 22 '25 18:03 tobiasBora

Thank you for further enhancing the code. I am currently traveling, will be back in a week. Maybe I manage to test it sooner. I will keep in touch.

dflvunoooooo avatar Mar 23 '25 08:03 dflvunoooooo

I checked the new version. Looks very good! At least for python and gnuplot. :) Thank you for your work! Sorry it did take me so long to check.

dflvunoooooo avatar Apr 17 '25 06:04 dflvunoooooo