KMET: Edit KM Objects as Text (Search & Replace) Version 1.2

I've uploaded version 1.2, which I believe fixes the problem. Please let me know if it works for you.

NOTE: If you have XML or JSON for a Macro that you previously got using KMET, you'll need to "get" it again.

1 Like

Perfect! Thanks for the quick update.

As an aside, do you recall if it was it once possible to manually paste xml for a new macro? (I think your action is modifying the plist).

I'm not sure what you're saying, but if you follow these steps:

  1. Click on the macro in the editor.
  2. Run the KMET copy or edit macro.
  3. Optionally make changes.
  4. Copy the changed XML or JSON to the clipboard.
  5. Use KMET to paste the result in.

You should end up with a second copy of the macro. Is that not happening?

Yes, the macro is working fine after the 1.2 update. The aside was about manually pasting xml.

In other words, I can copy an action as xml and paste it back as a new action. However, if I copy a macro as xml, I cannot paste that xml back into editor. Paste is not available as a menu item, and ⌘V does not work. I thought based on your previous comment that this capability was once there but went away. Maybe I misunderstood.

Dammit, I knew that was going to come up. I made the change in the wrong place, or more accurately, I should have made it in two places. And I thought about it after I posted the update.

When I get a chance later today, I'll work on that. SMH. I knew I should have fixed it right then. :slight_smile:

I hope I'm being clear. This has nothing to do with your macro. I'm just talking about the KM Editor itself. I can select and action and Edit>Copy as>Copy as XML, then ⌘V to get a duplicate action. If I do the same thing with a macro, I can't paste as a new macro. Your 1.2 update works great!

Yes, I understood. I need to post a question for Peter about that.

But for now, if I modify the KMET Paste macro, it'll be able to paste it in for us. I'll keep you posted.

Just uploaded new version 1.2a.

You can use [KMET] Paste Objects into KM to paste in XML that was retrieved with the KM Editor's "Copy as XML" command.


Using KMET to Edit Comments

In a workflow I'm trying to develop, I would like to be able to use KMET to generate and edit comment actions in the KM macros. But when I take any comment action or group containing a comment into JSON or XML to edit it, the comments are tagged as "Styled Text" or something like that, and are encoded binary, totally unreadable.

Is there any way of making the comment text human readable?


1 Like

I think its base64 encoded RTF, so you would need two pairs of transformations to work in that way.

  • Base64 ⇄ Plain ( /usr/bin/base64)
  • RTF ⇄ TXT (/usr/bin/textutil)

If you had the encoded contents of a <key>StyledText</key> <data> tag in a file called encoded.txt, you could try a command line pipe of this general pattern:

/usr/bin/base64 -d encoded.txt | /usr/bin/textutil -convert txt -stdin -stdout

Yeah, that's one I don't know how to do. I wish there was a "plainText" element.

Experimental notes:

I created a new action, a blank Comment, doing nothing to the default that's created. Editing that as XML with KMET, I see:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

I can edit the Comment Styled Text data to be empty and when I paste that into KM, it's a comment with everything else in place and empty text. Sweet. When I copy that new empty comment back into XML, I get the same five lines of encoded data.

Running through the same cycle with JSON, I get:

		"MacroActionType": "Comment",
		"Title": "Untitled",
		"ActionUID": 9694692,
		"StyledText": "\n\t\t41E4D515-C065-4C24-9859-EA2479C52CC9\n\t\tcnRmZAAAAAADAAAAAgAAAAcAAABUWFQucnRmAQAAAC6GAAAAKwAAAAEAAAB+\n\t\tAAAAe1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcY29jb2FydGYxNTA0XGNvY29h\n\t\tc3VicnRmODMwCntcZm9udHRibH0Ke1xjb2xvcnRibDtccmVkMjU1XGdyZWVu\n\t\tMjU1XGJsdWUyNTU7fQp7XCpcZXhwYW5kZWRjb2xvcnRibDs7fQp9AQAAACMA\n\t\tAAABAAAABwAAAFRYVC5ydGYQAAAAlmygWbYBAAAAAAAAAAAAAA==\n\t\t41E4D515-C065-4C24-9859-EA2479C52CC9\n\t\t"

It looks to me like the JSON has the same five lines as the XML, except delimited with \n\t\t, and with another ID line before and after:


In the JSON, if I delete the contents of the styled text field, the pasting doesn't happen. If I put the wrapper lines inside there, with nothing else in between, pasting works and I get a new Comment action, with blank text.

Trying /usr/bin/base64 will have to wait for another day.

1 Like