olivierverdier / python-latex-highlighting

LaTeX style for Python highlighting
BSD 3-Clause "New" or "Revised" License
453 stars 125 forks source link

Make a meaningful name for lstlistings style? #17

Closed user202729 closed 5 months ago

user202729 commented 6 months ago

Currently, the lstlistings style defined by the package is called mypython.

\lstdefinestyle{mypython}{

This causes a number of problems:


Suggestion: rename mypython to pythonhighlight-style (and mypythoninline to pythonhighlight-inline-style).

It would also be desirable to explicitly document the lstlistings style name in the documentation.

I don't think it's necessary to keep the old name around, because executing a grep in my texmf tree, there doesn't seem to be anything else that depends on the specific name.

olivierverdier commented 5 months ago

Sure! Would you mind making a pull request?

tobiasBora commented 5 months ago

Isn't it a bit dangerous to do it this way in a non backward-compatible way? Like this means that I would need to define two flavors of my library depending on the version provided by this library ^^'

user202729 commented 5 months ago

I say "anything else" means "anything else other than @tobiasBora 's library"... but I guess having an IfPackageLater in exchange for not having listings complain when a typical user define mypython style isn't too bad.

tobiasBora commented 5 months ago

I thought that users may use this as well, but this is not documented, so I guess this explains why my lib is the only one using this, so indeed I guess your change is fine and it is my issue if this is changed. But my issue with IfPackageLater is that it works only if the library was already loaded… but since I define the value of __ROBEXT_PYTHON_LSTINPUT_STYLE__ in the preamble, if the users loads robust-externalize first like in:

\usepackage{robust-externalize}
\usepackage{pythonhighlight}

then I will not be able to know which version is loaded (unless I load it myself, but then it will add compilation time even if the user does not use pythonhighlight)… Or maybe I can defer the definition of this to the end of the preamble, and check if it has not already been changed by the user… but I don't really like pushing things at the end of the preamble since it can be confusing for users that might expect it to be defined right after robust-externalize is loaded… but I don't see a much better solution.

olivierverdier commented 5 months ago

@tobiasBora what package is that exactly?

olivierverdier commented 5 months ago

To me this variable was just an internal variable with no significance. I just changed it because I understand the issue with strange error messages, otherwise this variable can be anything (and might change in a very distant future? 😄). Let me know if I can help solving your issue.

tobiasBora commented 5 months ago

It is for the library https://github.com/leo-colisson/robust-externalize In particular, I use it to allow people to execute a python code, and print the result next to it. I use your lib by default as I like your style, but to allow the user to customize it arbitrarily, I allow the user to customize the style with any arbitrary lst style. That's why I rely on the mypython style rather than the wrapper macro you provide.

and might change in a very distant future?

For the above mentioned reason, I would appreciate if you commit on not changing it in a non-backward compatible way ^^

Let me know if I can help solving your issue.

I guess there is not so much things you can do here, I'll try to see what I can do.

olivierverdier commented 5 months ago

Sure! I can’t see why it should change at a higher rate than the current frequency which is once every 13 years. 😄