Monday, November 08, 2010 at 12:03 AM.

system.verbs.builtins.html.data.standardMacros.nestedTableDisplayer

on nestedTableDisplayer (adrtable, border=1, linecolor="#FFFFFF") { //a recursive table display in HTML
	local (indentlevel = 0);
	on renderOneTable (adrtable) {
		local (htmltext = "");
		on add (s) {
			htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"};
		local (i, adritem);
		bundle { //add table head
			local (s = "<table ");
			if indentlevel > 0 {
				s = s + "width=\"100%\""};
			s = s + "border=\"" + border + "\" cellpadding=\"3\" cellspacing=\"0\">";
			add (s); indentlevel++};
		for i = 1 to sizeof (adrtable^) {
			adritem = @adrtable^ [i];
			add ("<tr bgcolor=\"" + linecolor + "\">"); indentlevel++;
			add ("<td valign=\"top\">" + nameof (adritem^) + ":</td>");
			add ("<td valign=\"top\" align=\"left\">"); indentlevel++;
			case typeof (adritem^) {
				tabletype {
					local (s = renderOneTable (adritem));
					s = string.mid (s, 1, sizeof (s) - 1); //pop off trailing \r
					local (oldlevel = indentlevel); indentlevel = 0;
					add (s);
					indentlevel = oldlevel};
				binarytype {
					add ("<font size=\"-1\">(binary, type = " + getbinarytype (adritem^) +  ", size = " + sizeof (adritem^) + ")</font>")}}
			else {
				local (s = string (adritem^));
				s = string.replaceall (s, "<", "<");
				if sizeof (s) == 0 {
					s = " "};
				if s contains "\r" {
					s = "<pre>" + s + "</pre>";
					s = string.replaceall (s, "\r\n", "\r")};
				add ("<font size=\"-1\">" + s + "</font>")};
			add ("</td>"); indentlevel--;
			add ("</tr>"); indentlevel--};
		add ("</table>"); indentlevel--;
		return (htmltext)};
	return (renderOneTable (adrtable))}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.