Difference between "html" and "htmlText" in clipboardData?

Richard Gaskin ambassador at fourthworld.com
Thu Feb 2 11:36:06 EST 2017

Mark Waddingham wrote:

 > On 2017-02-02 01:46, Richard Gaskin via use-livecode wrote:
 >> What is the difference between "LiveCode HTML text" and "LiveCode
 >> HTML format"?
 > Nothing - they are the same format in that context (the
 > clipboardData).
 > However,
 > you should use 'htmlText' and 'rtfText' in preference to 'html' and
 > 'rtf' as they are the new names.

Good choice - helps folks better anticipate the differences between LC's 
htmlText and the web's HTML.

 >> If there is no difference and they're both LC's htmlText, why two
 >> key names?
 > The difference comes about when you use 'the fullClipboardData'.
 > The fullClipboardData gives you access both to the engine's
 > synthesized data formats and the original data that was placed on
 > the clipboard.
 > In this context:
 >    - rtfText: LiveCode's rtfText format
 >    - htmlText: LiveCode's htmlText format
 >    - styledText: LiveCode's (array-based) styledText format
 >    - html: Only present if the data on the clipboard is actually HTML
 >    - rtf: Only present if the data on the clipboard is actually RTF
 > This is explained in more detail in the fullClipboardData entry.
 > I'd generally recommend not using 'the clipboardData' for new apps,
 > and using 'the fullClipboardData' instead. It allows you to put
 > multiple distinct data types on the clipboard, and does not use any
 > 'legacy' rules to determine what keys appear ('the clipboardData'
 > only allows a single actual datatype, so uses priority rules to
 > determine which you see).

That info is VERY useful - thank you!

My question arose because a forum user found an interesting workaround 
for making backgroundColor in text pastable into other applications - 
this post gets to the meat (the thread as a whole is long):

The code he offers there does far more stuff than I believe may be 
needed, but the crux of it is that he's modifying the 
clipboardData["html"] so that LC's htmlText becomes inline CSS:

   <font bgcolor="#444444">Hello</font>


   <span style="background-color: #444444">Hello</span>

He says this works well, that after he modifies the 
clipboardData["html"] he can then paste into other apps and preserve the 
background color for text runs.

This didn't seem right to me, since my understanding seems to fit what 
you've said here, that modifying any key of clipboardData will update 
the other keys to their closest match, and that only the 
fullClipboardData treats keys independently - is that correct?

If so, I don't understand how his code works.

But if my understanding is incorrect, it suggests perhaps there's a way 
that the clipboard routines modify the internal "htmlText" element to 
the closest match it can when setting the "text" element.  That doesn't 
seem logical, though, as it would require that LC have a CSS processor 
built-in, and I can't imagine you folks would be sitting on such a gem 
without providing an interface for it. :)

  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  Ambassador at FourthWorld.com                http://www.FourthWorld.com

More information about the use-livecode mailing list