Automatically detecting imported libraries

Author: odashiCreated Nov 12, 2022Updated May 2, 2024
Labelsfeature

Ref: #86

Sometimes users import libraries with custom names, and the current implementation of latexify does not recognize it without passing the custom config (this is not the current feature: tracked by #87)

We can anyway list up the all imported modules through globals(), and check if they contains some well known libraries. For example, if the user invoked import numpy as np, globals()["np"] should point to a module with __name__ == "numpy".

This is clever enough I think, but applying this involves environment-dependent behavior. I think this can be implemented as an additional NodeTransformer with a boolean switch which is turned off by default.