INTEGRAL DSL Reference Guide
Jump directly to:
::my.app.ToHTML(string, flags = 0)
This function takes an input string and returns a new string in which certain characters are converted to HTML entities or HTML tags. Specifically:
- & (ampersand) is always converted to &
- < (less than) is always converted to <
- > (greater than) is always converted to >
- " (double quote) is always converted to "
- \n (newline) is converted to <br /> but only if first bit in flags is set
- ' (single quote) is converted to ' but only if second bit in flags is set
Parameters
string
A string to be converted to HTML.
flags
A bitmask that tells the function what additional HTML conversions to perform, if any.
- If 1st bit is set, the \n (newline) character is converted to <br />
- If 2nd bit is set, the ' (single quote) character is converted to '
- Other bits are presently unused.
Return Value
The function returns a new string in which certain characters are converted to HTML entities or HTML tags as noted above.
Note 1
Certain characters have special significance in HTML and should be converted to HTML entities if they are to preserve their meaning. This function returns a string with these conversions made.
Example 1
local intro = ::my.app.ToHTML("John & Jill went to see \"Start Wars\" last weekend");
::my.app.Print(intro);
Result:
John & Jill went to see "Start Wars" last weekend.
Example 2
local my_list = ::my.app.ToHTML("John & Jill\nMark & Susan\nTom & Mary", 1);
::my.app.Print(my_list);
Result:
John & Jill<br />Mark & Susan<br />Tom & Mary