Tried your system @Nige_S , problem is, when I set the clipboard to styled text, the text that is then pasted to Workflowy loses the formatting. So I think the best bet would be to convert the public.html to public.rtf and see if it works. Do you know how to do it?
@ComplexPoint is a lot better at this kind of Clipboard data type manipulation that I am and will hopefully come up with something faster. In the meantime...
The Clipboard's public.html is encoded, and we can't use it directly as the input to textutil -- we have to decode it to a plain text string first. The "easy" way is with AppleScript and Perl:
/usr/bin/osascript -e 'the clipboard as «class HTML»' | /usr/bin/perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | /usr/bin/textutil -convert rtf -format html -stdin -stdout | pbcopy
...and I've included the textutil operation in there so we don't waste CPUs with another "Shell" Action for that. Putting it in a macro with Copy, S'n'R and Paste Actions:
Workflowy Test (Chrome, AS).kmmacros (3.7 KB)
Which, with the S'n'R as written (change "with" to "that includes"), will change this:
to:
At least -- it does in Chrome! Have a play and see how you get on.
I donât have at the moment a proper Macro, but Iâm just trying to perform some actions, see if they work, and then build them into a proper sequence.
Anyway, I tried a few things and discovered that Workflowy stores styles both in HTML and in rtf (at least in Safari), while KM only needs rtf.
So the following sentence in Workflowy:

Can be copied to the clipboard and then processed in different ways, only using the KM action âRemove Clipboard Flavors From System Clipboardâ:
- Remove all flavors (from Safari copy) except
public.htmlandpublic.rtfand then paste to Workflowy: every style is preserved. - Remove all flavors (from Safari or Vivaldi copy) except
public.html
and then paste to Workflowy: every style is preserved. - Remove all flavors (from Safari copy only, from Chrome and Vivaldi this is not possible) except
public.rtfand paste to Workflowy: only basic styles are preserved:

- Remove all flavors except
public.rtfand display clipboard in KM: every style is preserved:

So it seems like KM is able to process styles more effectively keeping everything inside rtf, while Workflowy stores everything inside HTML.
Therefore, since KM is not able to process HTML styles, it would seem that there is no native way (in KM) to do a search and replace with HTML formatted content and preserve the original styles.
Sorry I was in the middle of a big edit when you posted. See above for a macro that (I think!) will do what you want in Chrome.
Thank you @Nige_S for the macro! It does a great job at keeping basic styles (bold, underlined, italic) also in Chrome based browsers, but it doesnât work with more advanced formatting (highlights), probably due to HTML.
FWIW I would guess that things like highlights may be handled, in Workflowy's Chrome client, via CSS, and they may not include them in the HTML clipboard contents at all.
In the case of the Workflowy Safari client, they do put highlight colors into the public.rtf pasteboard item, but not into the public.html pasteboard item.
A quick check of their HTML pasteboard items show that highlighted text spans do retain the class names to which CSS coloring is attached in the web client, e.g.
class="colored bc-yellow"
class="colored bc-pink"
but there is not much that a macOS pasting application can do with that. You would have to design your own CSS, or obtain theirs (subject to licensing restrictions) specifying formatting for those class names, and add an additional custom process â rendering that into RTF.
Yes, it seems very complex, and probably unfeasible at the moment. Anyway thanks for all the help to all of you!


