webtagortext(
TEXT
)

The webtagortext( function prepares text for display in a web page.


Parameters

This function has one parameter:

text – text to be prepared for display. This may be regular text or raw HTML.


Description

This function prepares text for display in a web page. Normally it converts all characters that need special handling into HTML entities, for example &, < and >.

webtagortext("this & that") ☞ this &amp; that

However, if the text contains a closing HTML tab (anything beginning with </), the function will assume the text is raw HTML and no characters are removed. Since this text contains a </b> tag, it is assumed to be raw HTML and is not transformed in any way.

webtagortext("this is <b>very</b> important") ☞  this is <b>very</b> important 

Here is another example of raw HTML (because of the </i> tag.

webtagortext("this & <i>that</i>") ☞  this & <i>that</i>

Since this is raw HTML, the ampersand is not automatically converted into an HTML entity. If you want the ampersand to display properly in a web browser, you must manually include the entity (in this case &amp;) in the text.

webtagortext("this &amp; <i>that</i>") ☞  this &amp; <i>that</i>

There are actually three cases where the text is assumed to be raw HTML:

Basically, the webtagortext( tries to figure out if the text is regular text or raw HTML. If it is regular text it converts special characters to HTML entities, if it is raw HTML it leaves the text alone so that any HTML tags in the text will be rendered by the web browser. If you always want the text to be treated as regular text, even if it has HTML tags in it, use the webtext( function. However, if you use the webtext( function it is impossible to put HTML tags into the text so that they will be passed thru to the browser.

If the text contains empty HTML tags (<>), they will be removed. This allows you to “trick” the function into thinking text is raw HTML, even if it doesn’t contain </ or <img. In this example the ampersand is passed thru without being expanded into an HTML entity as it normally would be.

webtagortext("<>this & that<>") ☞ this & that

The example above is rather implausible; here is a more realistic example where this technique is used to allow the insertion of an HTML <hr> tag.

webtagortext("<>Up<hr>Down<>") ☞ Up<hr>Down

Without the leading and trailing <> the < and > characters would be expanded into HTML entities, like this.

webtagortext("Up<hr>Down") ☞ Up&lt;hr&gt;Down

See Also


History

VersionStatusNotes
1.0No ChangeCarried over from Panorama 6.0.