Tuesday, August 18, 2009 at 7:54 PM.

howtoSuite.renderOutline

on renderOutline (adroutline, adrtitle) {
	<<Changes
		<<8/8/09; 12:39:07 PM by DW
			<<Run the text through howtoSuite.postProcessText before returning. 
		<<7/23/09; 10:33:21 AM by DW
			<<If an item has subs, bolden it, and add a blue-arrow with a permalink at the end. This came up in the rssCloud walkthrough doc, it clearly needs section-level permalinks. 
				<<http://rsscloud.org/walkthrough.html
		<<8/5/08; 10:42:46 PM by DW
			<<The permalinks weren't permanent, use howtoSuite.getSectionLabel to generate the permalink labels.
	local (xmltext = op.outlinetoxml (adroutline), xstruct, fltitleset = false, headnum = 1);
	local (bluearrowimg = string (howtoSuite.data.html.blueArrowImg));
	xml.compile (xmltext, @xstruct);
	local (adropml = xml.getaddress (@xstruct, "opml"));
	local (adrbody = xml.getaddress (adropml, "body"));
	<<scratchpad.xstruct = xstruct
	local (htmltext = "", indentlevel = 0);
	on add (s) {
		htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r";};
	on dolevel (adrlevel) {
		local (adr);
		for adr in adrlevel {
			if nameof (adr^) endswith "outline" {
				local (flhassubs);
				bundle { //set flhassubs
					flhassubs = false;
					if sizeof (adr^) > 1 { //might have a sub
						local (adrsub);
						for adrsub in adr {
							if nameof (adrsub^) endswith "outline" {
								flhassubs = true;
								break}}}};
				bundle { //output the linetext
					local (s = xml.entitydecode (adr^.["/atts"].text, flAlphaEntities:true));
					if flhassubs { //indentlevel == 0
						<<local (label = "a" + string.padwithzeros (headnum++, 1))
						local (label = howtoSuite.getSectionLabel (s));
						add ("<h4><a name=\"" + label + "\"></a>" + s + " <a href=\"#" + label + "\">" + bluearrowimg + "</a></h4>");
						if not fltitleset { //first major head is the title of the document
							adrtitle^ = s;
							fltitleset = true}}
					else {
						add ("<p>" + s + "</p>")}};
				bundle { //dive into subs
					if flhassubs {
						if indentlevel > 0 {
							add ("<blockquote>")};
						indentlevel++;
						dolevel (adr);
						indentlevel--;
						if indentlevel > 0 {
							add ("</blockquote>")}}}}}};
	dolevel (adrbody);
	return (howtoSuite.postProcessText (htmltext))}



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.