Can KM tell if the System Clipboard contains "stylized" content as opposed to just "plain text"? e.g. some of the content contains bold text, italic text, underlined text? (or a more general/broader definition of "stylized" e.g. contains bullet points etc.) Thanks.
A script action (AppleScript / Javascript for Automation) can detect whether there is any public.rtf (rich text) content in the clipboard.
See, for example:
I can't seem to get this idea to work. My screenshot shows the CB History BEFORE running my test macro. The 2 Display Windows are from AFTER running my macro. My test macro sees everything in the CB History as "styled" inaccurately. Only CB2 is styled.
=EDIT===
It would seem that KM thinks both my CB1 and CB2 are "styled" as in this case they were both copied from TextEdit in RTF-mode. In reality my CB's will be copied from a Word DOCX file. I need to tell whether "what I have just copied from my DOCX contains styled text or not." Will this simple macro idea do that? Or is it just going to look at where the CB came from and define it as "styled" irrespective?
If what you need is not detection of RTF, but actual use of a particular format, such as bold or italic etc, then the obvious route might have a pseudo-code shape like:
if RTF then
let htmlCopy = html version of RTF
return (html does or doesn't contain string patterns like `<b>` or `<i>`)
else
definitely no special formats
end if
but ... a problem is that emphases like bold and italic are often achieved by subtler things like font choice and font weights, which are harder to recognise.
A clipboard copied from MS Word already has an HTML content, but it's very complex ...
and it raises the question when is a text 'stylised' and when is it not ?
If we copy the following in MS Word:
The HTML content in the clipboard is over 40,000 characters long, and not very simply reducible to styled or not styled
I can see this may get too complex and perhaps I can take a different approach.
In that case, then, IMO, your best bet is to use Word VBA to examine the style of the selection to determine if any character in the selection has what you consider to be "stylized".