Pretty-printing the code of a LibreOffice Calc macro

I could not find in LibreOffice Calc a way to print the code of a macro with syntax highlighting. Is there any good tool to do that on a Linux Machine?

Thanks a lot for your suggestion.
I am using LibreOffice 6.4.7.2 on a Xubuntu 20.04 machine.
I installed the LibreOffice script provider for python as advised for Ubuntu users.
Then I opened a code snippet in Writer and selected it. However no entry “Code Highlighter 2” appears in the format menu. Do you have any idea about what I’m doing wrong?

Sorry, I just discovered that it’s in the Tools menu.

But there is no choice for LibreOffice Basic. I tried “Automatic” and vb.net (visual basic?). In either case I get a popup window with a long error message (couldn’t find how to attach a screenshot).

You can select and copy LibreOffice dialog text, such as error messages.
There is an upload button on top of the text you are typing.

pip install Pygments
xray_module.odt (55.1 KB) (with vb.net option)

Thank you for your help.
I installed the Pygments package.
Then I removed the extension Code Highlighter 2 and re-added it to LibreOffice. This time I got a message telling that it requires LibreOffice 7.1 or higher (mine is 6.4.7.2).
So I added Code Highlighter 1.2 instead. However trying to process my code snippet with vb.net still produces the same error message:

Screenshot_2024-10-11_19-25-52

By the way, I don’t know what to do with xray_module.odt. Should it be added to LibreOffice as a basic macro?
Edit: I feel stupid, I just realized that you provided this file as an example of the results given by Code Highlighter! :flushed:

to solve the whole thing, I would take a notice about the (by User) installed Extensions, rename the whole user-config ( …libreoffice/4/user/ ) and then start with a new installed LO7.4 or higher …

Thanks for this suggestion. I was fearing that installing a new release (24.8.2) beside the distribution install would screw up my setup, but it did not. Using vb.net it works like a charm!
Many thanks to both of you and Villeroy for your help!

It’s just a huge chunk of Basic code. Xray is part of a library that helps to write macro code. Release Version 1.3.4 · hanya/MRI · GitHub
If you use the MRI extension, you don’t need Xray. Both projects were somewhat competitive to each other. Now they are orphaned but still helpful.