htmlText not supporting target in <a href="xxx">?

Richard Gaskin ambassador at fourthworld.com
Tue Jun 21 12:27:21 EDT 2016


Ton Kuypers wrote:

 > Hi Richard & Monte,
 >
 > The problem is that I am creating html text that will be stored in a
 > database, to be retrieved by a PHP site.
 > The user gets an easy interface to manipulate this html, but a major
 > issue is that when the user adds links to PDF files, they need to
 > open in a new window.
 > And the only way I know, is to add a “target” to the link…
 >
 > so now I’m kinda stuck… bummer :-(

As long as you keep in mind that htmlText is not HTML, you have the key 
to become unstuck.

One of my larger projects is an authoring toolkit to produce a web site 
of medical reference info.  Everything is authored in LiveCode fields in 
a very WYSIWYG way - with the new field object we even set the leading 
(using the spaceAbove paragraph property) to match the site's CSS. 
Nearly pixel-perfect, and super-convenient for our non-techie team of 
physicians to use.

And that's where I come in:  like most software, what it takes to 
transform a fluid WYSIWYG authoring environment into browser-ready HTML 
requires some work.  Not much, but some.

Parsing htmlText is MUCH easier than parsing HTML, since it's much more 
consistent.  You'll find as many different HTML styles as there are 
people writing web pages, but htmlText is always generated by the 
LiveCode engine with glorious reliable consistency.

There are many ways to transform htmlText into HTML, and some of those 
will depend on the specifics of what your authoring tool does and what 
you need to do with it on the Web.

But as a simple example, if you pass your htmlText through a function, 
perhaps something like this, you'll have the beginnings of a convenient 
way to do that transformation in one place, where you can refine and 
enhance it any time you need:


function htmlTextToHtml pData
   put offset("<a href=", pData) into tStart
   if tStart > 0 then
     put offset(">", pData, tStart) into tEnd
     put " target='_blank'>" into char (tStart+tEnd) of pData
   end if
   return pData
end htmlTextToHtml

-- 
  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