KM8: How Can I get Plain Text from a Comment Action?

You guys are hilarious! :slight_smile:

Crowd: We want rich text in out comments
Me: Ok, here you go
Crowd: Ahh, now we can’t mess around with them
Me: sigh.

:slight_smile:

It should be possible to write some JXA code that reads the RFD data in the XML and returns the string as plain text, or that generates the string from plain text and returns the RFD data.

Unfortunately, I’m not all that familiar with JXA either, so I don’t really know how to do it. The Objective C is:

Data to plain string:

[[[NSAttributedString alloc] initWithRTFD:data documentAttributes:nil] string];

String to data:

[[[NSAttributedString alloc] initWithString:s] RTFDFromRange:NSMakeRange(0,s.length) documentAttributes:@{}];

If they were translated to JXA then presumably that would be able to encode/decode the data to/from plain text (losing any formatting, obviously).

It’s not something I can add to Keyboard Maestro as such.

1 Like