Htmltext: storing data in markup

Richard Gaskin ambassador at fourthworld.com
Thu Jan 27 09:05:36 EST 2011


David Bovill wrote:

> Anyone got any suggestions / experience in using htmltext to store data /
> metadata. Most of the time is strips out any additional tags you might add
> (which is a great pity) - but I've found it useful to use markup like:
>
> <a name="some thing you want to store">For this text</a>
>
> Are there any other tags that can be used to markup text with metadata?

The name attribute is honored so long as the run of text it's applied to 
does not also have an href.

E.g. this works well for assigning arbitrary metadata to text runs:

    this is a <a name="howdy">test</a>.

With that htmlText, the text is rendered without a link and no 
linkClicked message is sent.  Instead you can use this to get the name data:

     get the linkText of the clickChunk

...or any other chunk expression like:

    get the linkText of word 5 of fld 1


As useful as that is, note that including an href for that segment will 
cause the name attribute data to be lost:

    this is a <a name="howdy" href="somelink">test</a>.

If you don't need links in the runs you need to apply metadata to, the 
name attribute should do what you need.


If you may also have links in some of those runs, you may be interested 
in this request for a linkData chunk property, which would allow us to 
use any number of attributes in <a> tags, returned in an array as with 
clipboardData and dragData:

<http://quality.runrev.com/qacenter/show_bug.cgi?id=9347>

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv




More information about the use-livecode mailing list