[Collater::] The Collater. To collate material generated by the weaver into finished, fully-woven files. @ \section{Collation.} This is the process of reading a template file, substituting material into placeholders in it, and writing the result. The collater needs to operate as a little processor interpreting a meta-language all of its very own, with a stack for holding nested repeat loops, and a program counter and -- well, and nothing else to speak of, in fact, except for the slightly unusual way that loop variables provide context by changing the subject of what is discussed rather than by being accessed directly. For convenience, we provide three ways to call: <<*>>= void Collater::for_web_and_pattern(text_stream *OUT, web *W, weave_pattern *pattern, filename *F, filename *into) { Collater::collate(OUT, W, I"", F, pattern, NULL, NULL, NULL, into); } void Collater::for_order(text_stream *OUT, weave_order *wv, filename *F, filename *into) { Collater::collate(OUT, wv->weave_web, wv->weave_range, F, wv->pattern, wv->navigation, wv->breadcrumbs, wv, into); } void Collater::collate(text_stream *OUT, web *W, text_stream *range, filename *template_filename, weave_pattern *pattern, filename *nav_file, linked_list *crumbs, weave_order *wv, filename *into) { collater_state actual_ies = Collater::initial_state(W, range, template_filename, pattern, nav_file, crumbs, wv, into); collater_state *ies = &actual_ies; Collater::process(OUT, ies); } @ The current state of the processor is recorded in the following. <<*>>= #define TRACE_COLLATER_EXECUTION FALSE /* set true for debugging */ #define MAX_TEMPLATE_LINES 8192 /* maximum number of lines in template */ #define CI_STACK_CAPACITY 8 /* maximum recursion of chapter/section iteration */ <<*>>= typedef struct collater_state { struct web *for_web; struct text_stream *tlines[MAX_TEMPLATE_LINES]; int no_tlines; int repeat_stack_level[CI_STACK_CAPACITY]; struct linked_list_item *repeat_stack_variable[CI_STACK_CAPACITY]; struct linked_list_item *repeat_stack_threshold[CI_STACK_CAPACITY]; int repeat_stack_startpos[CI_STACK_CAPACITY]; int sp; /* And this is our stack pointer for tracking of loops */ struct text_stream *restrict_to_range; struct weave_pattern *nav_pattern; struct filename *nav_file; struct linked_list *crumbs; int inside_navigation_submenu; struct filename *errors_at; struct weave_order *wv; struct filename *into_file; struct linked_list *modules; /* of [[module]] */ } collater_state; @ Note the unfortunate maximum size limit on the template file. It means that really humungous Javascript files in plugins might have trouble, though if so, they can always be subdivided. <<*>>= collater_state Collater::initial_state(web *W, text_stream *range, filename *template_filename, weave_pattern *pattern, filename *nav_file, linked_list *crumbs, weave_order *wv, filename *into) { collater_state cls; cls.no_tlines = 0; cls.restrict_to_range = Str::duplicate(range); cls.sp = 0; cls.inside_navigation_submenu = FALSE; cls.for_web = W; cls.nav_pattern = pattern; cls.nav_file = nav_file; cls.crumbs = crumbs; cls.errors_at = template_filename; cls.wv = wv; cls.into_file = into; cls.modules = NEW_LINKED_LIST(module); if (W) { int c = LinkedLists::len(W->md->as_module->dependencies); if (c > 0) <
>; } <>; return cls; } <>= module **module_array = Memory::calloc(c, sizeof(module *), ARRAY_SORTING_MREASON); module *M; int d=0; LOOP_OVER_LINKED_LIST(M, module, W->md->as_module->dependencies) module_array[d++] = M; Collater::sort_web(W); qsort(module_array, (size_t) c, sizeof(module *), Collater::sort_comparison); for (int d=0; d>= TextFiles::read(template_filename, FALSE, "can't find contents template", TRUE, Collater::temp_line, NULL, &cls); if (TRACE_COLLATER_EXECUTION) PRINT("Read template <%f>: %d line(s)\n", template_filename, cls.no_tlines); if (cls.no_tlines >= MAX_TEMPLATE_LINES) PRINT("Warning: template <%f> truncated after %d line(s)\n", template_filename, cls.no_tlines); <<*>>= void Collater::temp_line(text_stream *line, text_file_position *tfp, void *v_ies) { collater_state *cls = (collater_state *) v_ies; if (cls->no_tlines < MAX_TEMPLATE_LINES) cls->tlines[cls->no_tlines++] = Str::duplicate(line); } @ Running the engine... <<*>>= void Collater::process(text_stream *OUT, collater_state *cls) { int lpos = 0; /* This is our program counter: a line number in the template */ while (lpos < cls->no_tlines) { match_results mr = Regexp::create_mr(); TEMPORARY_TEXT(tl) Str::copy(tl, cls->tlines[lpos++]); /* Fetch the line at the program counter and advance */ <>; WRITE("%S\n", tl); /* Copy the now finished line to the output */ DISCARD_TEXT(tl) CYCLE: ; Regexp::dispose_of(&mr); } if (cls->inside_navigation_submenu) WRITE(""); cls->inside_navigation_submenu = FALSE; } <>= if (Regexp::match(&mr, tl, L"(%c*?) ")) Str::copy(tl, mr.exp[0]); /* Strip trailing spaces */ if (TRACE_COLLATER_EXECUTION) <>; if ((Regexp::match(&mr, tl, L"%[%[(%c+)%]%]")) || (Regexp::match(&mr, tl, L" %[%[(%c+)%]%]"))) { TEMPORARY_TEXT(command) Str::copy(command, mr.exp[0]); <>; <>; <>; <>; <>; DISCARD_TEXT(command) } <>; <>; <>; @ \section{The repeat stack and loops.} This is used only for debugging: <>= PRINT("%04d: %S\nStack:", lpos-1, tl); for (int j=0; jsp; j++) { if (cls->repeat_stack_level[j] == CHAPTER_LEVEL) PRINT(" %d: %S/%S", j, ((chapter *) CONTENT_IN_ITEM(cls->repeat_stack_variable[j], chapter))->md->ch_range, ((chapter *) CONTENT_IN_ITEM(cls->repeat_stack_threshold[j], chapter))->md->ch_range); else if (cls->repeat_stack_level[j] == SECTION_LEVEL) PRINT(" %d: %S/%S", j, ((section *) CONTENT_IN_ITEM(cls->repeat_stack_variable[j], section))->md->sect_range, ((section *) CONTENT_IN_ITEM(cls->repeat_stack_threshold[j], section))->md->sect_range); } PRINT("\n"); @ We start the direct commands with Select, which is implemented as a one-iteration loop in which the loop variable has the given section or chapter as its value during the sole iteration. <>= match_results mr = Regexp::create_mr(); if (Regexp::match(&mr, command, L"Select (%c*)")) { chapter *C; section *S; LOOP_OVER_LINKED_LIST(C, chapter, cls->for_web->chapters) LOOP_OVER_LINKED_LIST(S, section, C->sections) if (Str::eq(S->md->sect_range, mr.exp[0])) { Collater::start_CI_loop(cls, SECTION_LEVEL, S_item, S_item, lpos); Regexp::dispose_of(&mr); goto CYCLE; } LOOP_OVER_LINKED_LIST(C, chapter, cls->for_web->chapters) if (Str::eq(C->md->ch_range, mr.exp[0])) { Collater::start_CI_loop(cls, CHAPTER_LEVEL, C_item, C_item, lpos); Regexp::dispose_of(&mr); goto CYCLE; } Errors::at_position("don't recognise the chapter or section abbreviation range", cls->errors_at, lpos); Regexp::dispose_of(&mr); goto CYCLE; } @ Conditionals: <>= if (Regexp::match(&mr, command, L"If (%c*)")) { text_stream *condition = mr.exp[0]; int level = IF_FALSE_LEVEL; if (Str::eq(condition, I"Chapters")) { if (cls->for_web->md->chaptered) level = IF_TRUE_LEVEL; } else if (Str::eq(condition, I"Modules")) { if (LinkedLists::len(cls->modules) > 0) level = IF_TRUE_LEVEL; } else if (Str::eq(condition, I"Module Page")) { module *M = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, MODULE_LEVEL), module); if ((M) && (Colonies::find(M->module_name))) level = IF_TRUE_LEVEL; } else if (Str::eq(condition, I"Module Purpose")) { module *M = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, MODULE_LEVEL), module); if (M) { TEMPORARY_TEXT(url) TEMPORARY_TEXT(purpose) WRITE_TO(url, "%p", M->module_location); Readme::write_var(purpose, url, I"Purpose"); if (Str::len(purpose) > 0) level = IF_TRUE_LEVEL; DISCARD_TEXT(url) DISCARD_TEXT(purpose) } } else if (Str::eq(condition, I"Chapter Purpose")) { chapter *C = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, CHAPTER_LEVEL), chapter); if ((C) && (Str::len(C->md->rubric) > 0)) level = IF_TRUE_LEVEL; } else if (Str::eq(condition, I"Section Purpose")) { section *S = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, SECTION_LEVEL), section); if ((S) && (Str::len(S->sect_purpose) > 0)) level = IF_TRUE_LEVEL; } else { Errors::at_position("don't recognise the condition", cls->errors_at, lpos); } Collater::start_CI_loop(cls, level, NULL, NULL, lpos); Regexp::dispose_of(&mr); goto CYCLE; } <>= if (Regexp::match(&mr, command, L"Else")) { if (cls->sp <= 0) { Errors::at_position("Else without If", cls->errors_at, lpos); goto CYCLE; } switch (cls->repeat_stack_level[cls->sp-1]) { case SECTION_LEVEL: case CHAPTER_LEVEL: Errors::at_position("Else not matched with If", cls->errors_at, lpos); break; case IF_TRUE_LEVEL: cls->repeat_stack_level[cls->sp-1] = IF_FALSE_LEVEL; break; case IF_FALSE_LEVEL: cls->repeat_stack_level[cls->sp-1] = IF_TRUE_LEVEL; break; } Regexp::dispose_of(&mr); goto CYCLE; } @ Next, a genuine loop beginning: <>= int loop_level = 0; if (Regexp::match(&mr, command, L"Repeat Module")) loop_level = MODULE_LEVEL; if (Regexp::match(&mr, command, L"Repeat Chapter")) loop_level = CHAPTER_LEVEL; if (Regexp::match(&mr, command, L"Repeat Section")) loop_level = SECTION_LEVEL; if (loop_level != 0) { linked_list_item *from = NULL, *to = NULL; linked_list_item *CI = FIRST_ITEM_IN_LINKED_LIST(chapter, cls->for_web->chapters); while ((CI) && (CONTENT_IN_ITEM(CI, chapter)->md->imported)) CI = NEXT_ITEM_IN_LINKED_LIST(CI, chapter); if (loop_level == MODULE_LEVEL) <>; if (loop_level == CHAPTER_LEVEL) <>; if (loop_level == SECTION_LEVEL) <>; Collater::start_CI_loop(cls, loop_level, from, to, lpos); goto CYCLE; } <>= from = FIRST_ITEM_IN_LINKED_LIST(module, cls->modules); to = LAST_ITEM_IN_LINKED_LIST(module, cls->modules); <>= from = CI; to = LAST_ITEM_IN_LINKED_LIST(chapter, cls->for_web->chapters); if (Str::eq_wide_string(cls->restrict_to_range, L"0") == FALSE) { chapter *C; LOOP_OVER_LINKED_LIST(C, chapter, cls->for_web->chapters) if (Str::eq(C->md->ch_range, cls->restrict_to_range)) { from = C_item; to = from; break; } } <>= chapter *within_chapter = CONTENT_IN_ITEM(Collater::heading_topmost_on_stack(cls, CHAPTER_LEVEL), chapter); if (within_chapter == NULL) { if (CI) { chapter *C = CONTENT_IN_ITEM(CI, chapter); from = FIRST_ITEM_IN_LINKED_LIST(section, C->sections); } chapter *LC = LAST_IN_LINKED_LIST(chapter, cls->for_web->chapters); if (LC) to = LAST_ITEM_IN_LINKED_LIST(section, LC->sections); } else { from = FIRST_ITEM_IN_LINKED_LIST(section, within_chapter->sections); to = LAST_ITEM_IN_LINKED_LIST(section, within_chapter->sections); } @ And at the other bookend: <>= int end_form = -1; if (Regexp::match(&mr, command, L"End Repeat")) end_form = 1; if (Regexp::match(&mr, command, L"End Select")) end_form = 2; if (Regexp::match(&mr, command, L"End If")) end_form = 3; if (end_form > 0) { if (cls->sp <= 0) { Errors::at_position("stack underflow on contents template", cls->errors_at, lpos); goto CYCLE; } switch (cls->repeat_stack_level[cls->sp-1]) { case MODULE_LEVEL: case CHAPTER_LEVEL: case SECTION_LEVEL: if (end_form == 3) { Errors::at_position("End If not matched with If", cls->errors_at, lpos); goto CYCLE; } break; case IF_TRUE_LEVEL: case IF_FALSE_LEVEL: if (end_form != 3) { Errors::at_position("If not matched with End If", cls->errors_at, lpos); goto CYCLE; } break; } switch (cls->repeat_stack_level[cls->sp-1]) { case MODULE_LEVEL: <>; break; case CHAPTER_LEVEL: <>; break; case SECTION_LEVEL: <>; break; case IF_TRUE_LEVEL: <>; break; case IF_FALSE_LEVEL: <>; break; } goto CYCLE; } <>= linked_list_item *CI = cls->repeat_stack_variable[cls->sp-1]; if (CI == cls->repeat_stack_threshold[cls->sp-1]) Collater::end_CI_loop(cls); else { cls->repeat_stack_variable[cls->sp-1] = NEXT_ITEM_IN_LINKED_LIST(CI, chapter); lpos = cls->repeat_stack_startpos[cls->sp-1]; /* Back round loop */ } <>= linked_list_item *CI = cls->repeat_stack_variable[cls->sp-1]; if (CI == cls->repeat_stack_threshold[cls->sp-1]) Collater::end_CI_loop(cls); else { cls->repeat_stack_variable[cls->sp-1] = NEXT_ITEM_IN_LINKED_LIST(CI, chapter); lpos = cls->repeat_stack_startpos[cls->sp-1]; /* Back round loop */ } <>= linked_list_item *SI = cls->repeat_stack_variable[cls->sp-1]; if ((SI == cls->repeat_stack_threshold[cls->sp-1]) || (NEXT_ITEM_IN_LINKED_LIST(SI, section) == NULL)) Collater::end_CI_loop(cls); else { cls->repeat_stack_variable[cls->sp-1] = NEXT_ITEM_IN_LINKED_LIST(SI, section); lpos = cls->repeat_stack_startpos[cls->sp-1]; /* Back round loop */ } <>= Collater::end_CI_loop(cls); @ It can happen that a section loop, at least, is empty: <>= for (int rstl = cls->sp-1; rstl >= 0; rstl--) if (cls->repeat_stack_level[cls->sp-1] == SECTION_LEVEL) { linked_list_item *SI = cls->repeat_stack_threshold[cls->sp-1]; if (NEXT_ITEM_IN_LINKED_LIST(SI, section) == cls->repeat_stack_variable[cls->sp-1]) goto CYCLE; } <>= for (int j=cls->sp-1; j>=0; j--) if (cls->repeat_stack_level[j] == IF_FALSE_LEVEL) goto CYCLE; @ If called with the non-conditional levels, the following function returns the topmost item. It's never called for [[IF_TRUE_LEVEL|]]or [[IF_FALSE_LEVEL]]. <<*>>= linked_list_item *Collater::heading_topmost_on_stack(collater_state *cls, int level) { for (int rstl = cls->sp-1; rstl >= 0; rstl--) if (cls->repeat_stack_level[rstl] == level) return cls->repeat_stack_variable[rstl]; return NULL; } @ This is the function for starting a loop or code block, which stacks up the details, and similarly for ending it by popping them again: <<*>>= #define MODULE_LEVEL 1 #define CHAPTER_LEVEL 2 #define SECTION_LEVEL 3 #define IF_TRUE_LEVEL 4 #define IF_FALSE_LEVEL 5 <<*>>= void Collater::start_CI_loop(collater_state *cls, int level, linked_list_item *from, linked_list_item *to, int pos) { if (cls->sp < CI_STACK_CAPACITY) { cls->repeat_stack_level[cls->sp] = level; cls->repeat_stack_variable[cls->sp] = from; cls->repeat_stack_threshold[cls->sp] = to; cls->repeat_stack_startpos[cls->sp++] = pos; } } void Collater::end_CI_loop(collater_state *cls) { cls->sp--; } @ \section{Variable substitutions.} We can now forget about this tiny stack machine: the one task left is to take a line from the template, and make substitutions of variables into its square-bracketed parts. Note that we do not allow this to recurse, i.e., if [[[[X]]]] substitutes into text which itself contains a [[[[...]]]] notation, then we do not expand that inner one. If we did, then the value of the bibliographic variable [[[[Code]]]], used by the HTML renderer, would cause a modest-sized explosion on some pages. <>= TEMPORARY_TEXT(rewritten) int slen, spos; while ((spos = Regexp::find_expansion(tl, '[', '[', ']', ']', &slen)) >= 0) { TEMPORARY_TEXT(varname) TEMPORARY_TEXT(substituted) TEMPORARY_TEXT(tail) Str::substr(rewritten, Str::start(tl), Str::at(tl, spos)); Str::substr(varname, Str::at(tl, spos+2), Str::at(tl, spos+slen-2)); Str::substr(tail, Str::at(tl, spos+slen), Str::end(tl)); match_results mr = Regexp::create_mr(); if (Bibliographic::data_exists(cls->for_web->md, varname)) { <>; } else if (Regexp::match(&mr, varname, L"Navigation")) { <>; } else if (Regexp::match(&mr, varname, L"Breadcrumbs")) { <>; } else if (Str::eq_wide_string(varname, L"Plugins")) { <>; } else if (Regexp::match(&mr, varname, L"Complete (%c+)")) { text_stream *detail = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Module (%c+)")) { text_stream *detail = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Chapter (%c+)")) { text_stream *detail = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Section (%c+)")) { text_stream *detail = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Docs")) { <>; } else if (Regexp::match(&mr, varname, L"Assets")) { <>; } else if (Regexp::match(&mr, varname, L"URL \"(%c+)\"")) { text_stream *link_text = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Link \"(%c+)\"")) { text_stream *link_text = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Menu \"(%c+)\"")) { text_stream *menu_name = mr.exp[0]; <>; } else if (Regexp::match(&mr, varname, L"Item \"(%c+)\"")) { text_stream *item_name = mr.exp[0]; text_stream *icon_text = NULL; <>; text_stream *link_text = item_name; <>; } else if (Regexp::match(&mr, varname, L"Item \"(%c+)\" -> (%c+)")) { text_stream *item_name = mr.exp[0]; text_stream *link_text = mr.exp[1]; text_stream *icon_text = NULL; <>; <>; } else { WRITE_TO(substituted, "%S", varname); if (Regexp::match(&mr, varname, L"%i+%c*")) PRINT("Warning: unable to resolve command '%S'\n", varname); } Regexp::dispose_of(&mr); Str::clear(tl); WRITE_TO(rewritten, "%S", substituted); WRITE_TO(tl, "%S", tail); DISCARD_TEXT(tail) DISCARD_TEXT(varname) DISCARD_TEXT(substituted) } WRITE_TO(rewritten, "%S", tl); Str::clear(tl); Str::copy(tl, rewritten); DISCARD_TEXT(rewritten) @ This is why, for instance, [[[[Author]]]] is replaced by the author's name: <>= WRITE_TO(substituted, "%S", Bibliographic::get_datum(cls->for_web->md, varname)); @ [[[[Navigation]]]] substitutes to the content of the sidebar navigation file; this will recursively call The Collater, in fact. <>= if (cls->nav_file) { if (TextFiles::exists(cls->nav_file)) Collater::collate(substituted, cls->for_web, cls->restrict_to_range, cls->nav_file, cls->nav_pattern, NULL, NULL, cls->wv, cls->into_file); else Errors::fatal_with_file("unable to find navigation file", cls->nav_file); } else { PRINT("Warning: no sidebar links will be generated, as -navigation is unset"); } @ A trail of breadcrumbs, used for overhead navigation in web pages. <>= Colonies::drop_initial_breadcrumbs(substituted, cls->into_file, cls->crumbs); <>= Assets::include_relevant_plugins(OUT, cls->nav_pattern, cls->for_web, cls->wv, cls->into_file); @ We store little about the complete-web-in-one-file PDF: <>= if (swarm_leader) if (Formats::substitute_post_processing_data(substituted, swarm_leader, detail, cls->nav_pattern) == FALSE) WRITE_TO(substituted, "%S for complete web", detail); @ And here for Modules: <>= module *M = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, MODULE_LEVEL), module); if (M == NULL) Errors::at_position("no module is currently selected", cls->errors_at, lpos); else <>; <>= if (Str::eq_wide_string(detail, L"Title")) { text_stream *owner = Collater::module_owner(M, cls->for_web); if (Str::len(owner) > 0) WRITE_TO(substituted, "%S/", owner); WRITE_TO(substituted, "%S", M->module_name); } else if (Str::eq_wide_string(detail, L"Page")) { if (Colonies::find(M->module_name)) Colonies::reference_URL(substituted, M->module_name, cls->into_file); } else if (Str::eq_wide_string(detail, L"Purpose")) { TEMPORARY_TEXT(url) WRITE_TO(url, "%p", M->module_location); Readme::write_var(substituted, url, I"Purpose"); DISCARD_TEXT(url) } else { WRITE_TO(substituted, "%S for %S", varname, M->module_name); } @ And here for Chapters: <>= chapter *C = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, CHAPTER_LEVEL), chapter); if (C == NULL) Errors::at_position("no chapter is currently selected", cls->errors_at, lpos); else <>; <>= if (Str::eq_wide_string(detail, L"Title")) { Str::copy(substituted, C->md->ch_title); } else if (Str::eq_wide_string(detail, L"Code")) { Str::copy(substituted, C->md->ch_range); } else if (Str::eq_wide_string(detail, L"Purpose")) { Str::copy(substituted, C->md->rubric); } else if (Formats::substitute_post_processing_data(substituted, C->ch_weave, detail, cls->nav_pattern)) { ; } else { WRITE_TO(substituted, "%S for %S", varname, C->md->ch_title); } @ And this is a very similar construction for Sections. <>= section *S = CONTENT_IN_ITEM( Collater::heading_topmost_on_stack(cls, SECTION_LEVEL), section); if (S == NULL) Errors::at_position("no section is currently selected", cls->errors_at, lpos); else <>; <>= if (Str::eq_wide_string(detail, L"Title")) { Str::copy(substituted, S->md->sect_title); } else if (Str::eq_wide_string(detail, L"Purpose")) { Str::copy(substituted, S->sect_purpose); } else if (Str::eq_wide_string(detail, L"Code")) { Str::copy(substituted, S->md->sect_range); } else if (Str::eq_wide_string(detail, L"Lines")) { WRITE_TO(substituted, "%d", S->sect_extent); } else if (Str::eq_wide_string(detail, L"Source")) { WRITE_TO(substituted, "%f", S->md->source_file_for_section); } else if (Str::eq_wide_string(detail, L"Page")) { Colonies::section_URL(substituted, S->md); } else if (Str::eq_wide_string(detail, L"Paragraphs")) { WRITE_TO(substituted, "%d", S->sect_paragraphs); } else if (Str::eq_wide_string(detail, L"Mean")) { int denom = S->sect_paragraphs; if (denom == 0) denom = 1; WRITE_TO(substituted, "%d", S->sect_extent/denom); } else if (Formats::substitute_post_processing_data(substituted, S->sect_weave, detail, cls->nav_pattern)) { ; } else { WRITE_TO(substituted, "%S for %S", varname, S->md->sect_title); } @ These commands are all used in constructing relative URLs, especially for navigation purposes. <>= Pathnames::relative_URL(substituted, Filenames::up(cls->into_file), Pathnames::from_text(Colonies::home())); <>= pathname *P = Colonies::assets_path(); if (P == NULL) P = Filenames::up(cls->into_file); Pathnames::relative_URL(substituted, Filenames::up(cls->into_file), P); <>= Pathnames::relative_URL(substituted, Filenames::up(cls->into_file), Pathnames::from_text(link_text)); <>= WRITE_TO(substituted, "into_file); WRITE_TO(substituted, "\">"); <>= if (cls->inside_navigation_submenu) WRITE_TO(substituted, ""); WRITE_TO(substituted, "

%S