webtagortext(
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:

- If the text contains `</`
- If the text contains `<img`
- If the text begins with `<` and ends with `>`

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

- cgitest -- tests a CGI procedure.
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- info("httprequestinprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- info("webclientsessioninprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- serverrunning( -- returns true if this code is running on a Panorama server, or false if it is running in single user mode or on a client.
- serverstatus( -- returns a dictionary describing the current status of Panorama X Server.
- URL Tool Menu (Web Debugging) -- tool with popup menu to assist with debugging web procedures.
- urlfilename( -- extracts the filename from a complete url.
- urlpath( -- extracts the path from a URL.
- Web Error Pages -- customizing the server response when an error occurs.
- webhomesubfolder( -- returns the folder ID of a subfolder of the web server's home folder.
- webserverinfo( -- retrieves additional information about the web server and the current browser request.
- webtext( -- converts a number or regular text into text encoded for display in a web browser.

History

Version | Status | Notes
1.0 | No Change | Carried over from Panorama 6.0.