morbac / xmltools

XML Tools plugin for Notepad++
GNU General Public License v3.0
257 stars 57 forks source link

Request/Question: xml-tool "pretty print - indent attributes" via commandline or in batch #199

Open ukr966 opened 1 year ago

ukr966 commented 1 year ago

Hello xml tool community, my request is probably a little unusual. First of all: I am very grateful for the function "pretty print - indent attributes".

But now I am dealing with a large amount of files and I was looking for a way to read in all the xml files in a folder via python and put them back in another folder in a new format (just "pretty print - indent attributes"). I tried desperately to find a library, but none supported "indent attributes".

So my idea now is to use Notepad++ via Commandline and call the plugin. But I can't get it to work. Well, notepad opens, also synthax-hilightning is switched on, but I don't get the xml-tools with the selection "pretty print - indent attributes" started. Another idea would be to simulate typing "Ctrl+Alt+Shift+A", but I haven't found that either.

Of course, it would also be nice to automate the "save as" in the new folder. Optimally, Notepad++ would not even have to open visibly.

But I have no idea what would be possible. Can anyone give me a tip?

Let me summarise once again:

  1. call Notepad++ via commandline with input folder (and input file, or "*.abc")
  2. incl. call xml-tool "pretty print - indent attributes".
  3. storage in the specified output folder

When I think about it while writing, I just have the question, if it is not possible to call the plugin directly from python, without Notepad++? But i would be glad for any idea

ukr966 commented 1 year ago

Unfortunately, I have not found a way to access npp directly with the xml tool "pretty print - attribute indent", but only by simulated hotkey input after opening Notepad with the selected file. I then closed npp with hotkey Alt+F4 and confirmed the saving with hotkey "return".

Unfortunately, I could not catch the screen output, so it flickers "quite a bit" when many files are edited one after the other.

That's why I have now implemented the attribute indent myself in python, at least for my purposes. It is of course much faster 😂