/* Output the footnotes. We are at the end of the current node. */ void output_pending_notes (void) { FN *footnote = pending_notes; if (!pending_notes) return; if (html) { add_html_block_elt ("<div class=\"footnote\">\n<hr>\n"); /* We add an anchor here so @printindex can refer to this point (as the node name) for entries defined in footnotes. */ if (!splitting) add_word ("<a name=\"texinfo-footnotes-in-document\"></a>"); add_word_args ("<h4>%s</h4>", (char *) _("Footnotes")); } else switch (footnote_style) { case separate_node: { char *old_current_node = current_node; char *old_command = xstrdup (command); already_outputting_pending_notes++; execute_string ("%cnode %s-Footnotes,,,%s\n", COMMAND_PREFIX, current_node, current_node); already_outputting_pending_notes--; current_node = old_current_node; free (command); command = old_command; } break; case end_node: close_paragraph (); in_fixed_width_font++; /* This string should be translated according to the @documentlanguage, not the current LANG. We can't do that yet, so leave it in English. */ execute_string ("---------- Footnotes ----------\n\n"); in_fixed_width_font--; break; } /* Handle the footnotes in reverse order. */ { int save_in_fixed_width_font = in_fixed_width_font; FN **array = xmalloc ((footnote_count + 1) * sizeof (FN *)); array[footnote_count] = NULL; while (--footnote_count > -1) { array[footnote_count] = footnote; footnote = footnote->next; } filling_enabled = 1; indented_fill = 1; in_fixed_width_font = 0; while ((footnote = array[++footnote_count])) { if (html) { /* Make the text of every footnote begin a separate paragraph. */ add_html_block_elt ("<p class=\"footnote\"><small>"); /* Make footnote number a link to its definition. */ add_word_args ("[<a name=\"fn-%d\" href=\"#fnd-%d\">%d</a>]", footnote->number, footnote->number, footnote->number); add_word ("</small> "); already_outputting_pending_notes++; execute_string ("%s", footnote->note); already_outputting_pending_notes--; add_word ("</p>\n"); } else { char *old_current_node = current_node; char *old_command = xstrdup (command); already_outputting_pending_notes++; execute_string ("%canchor{%s-Footnote-%d}(%s) %s", COMMAND_PREFIX, current_node, footnote->number, footnote->marker, footnote->note); already_outputting_pending_notes--; current_node = old_current_node; free (command); command = old_command; } close_paragraph (); } if (html) add_html_block_elt ("<hr></div>"); close_paragraph (); free (array); in_fixed_width_font = save_in_fixed_width_font; } free_pending_notes (); }
static void contents_update_html (void) { int i; int k; int last_level; /* does exist any toc? */ if (!toc_counter) /* no, so return to sender ;-) */ return; add_html_block_elt_args ("\n<div class=\"contents\">\n<h2>%s</h2>\n<ul>\n", gdt("Table of Contents")); last_level = toc_entry_alist[0]->level; for (i = 0; i < toc_counter; i++) { if (toc_entry_alist[i]->level > last_level) { /* unusual, but it is possible @chapter ... @subsubsection ... ? */ for (k = 0; k < (toc_entry_alist[i]->level-last_level); k++) add_html_block_elt ("<ul>\n"); } else if (toc_entry_alist[i]->level < last_level) { /* @subsubsection ... @chapter ... this IS usual.*/ for (k = 0; k < (last_level-toc_entry_alist[i]->level); k++) add_word ("</li></ul>\n"); } /* No double entries in TOC. */ if (!(i && strcmp (toc_entry_alist[i]->name, toc_entry_alist[i-1]->name) == 0)) { /* each toc entry is a list item. */ add_word ("<li>"); /* Insert link -- to an external file if splitting, or within the current document if not splitting. */ add_word ("<a "); /* For chapters (only), insert an anchor that the short contents will link to. */ if (toc_entry_alist[i]->level == 0) { char *p = toc_entry_alist[i]->name; /* toc_entry_alist[i]->name has the form `foo">bar', that is, it includes both the node name and anchor text. We need to find where `foo', the node name, ends, and use that in toc_FOO. */ while (*p && *p != '"') p++; add_word_args ("name=\"toc_%.*s\" ", p - toc_entry_alist[i]->name, toc_entry_alist[i]->name); /* save the link if necessary */ if (internal_links_stream) { fprintf (internal_links_stream, "%s#toc_%.*s\ttoc\t%s\n", splitting ? toc_entry_alist[i]->html_file : "", p - toc_entry_alist[i]->name, toc_entry_alist[i]->name, p + 2); } } add_word_args ("href=\"%s#%s</a>\n", splitting ? toc_entry_alist[i]->html_file : "", toc_entry_alist[i]->name); } last_level = toc_entry_alist[i]->level; } /* Go back to start level. */ if (toc_entry_alist[0]->level < last_level) for (k = 0; k < (last_level-toc_entry_alist[0]->level); k++) add_word ("</li></ul>\n"); add_word ("</li></ul>\n</div>\n\n"); }
/* Make the defun type insertion. TYPE says which insertion this is. X_P, if nonzero, says not to start a new insertion. */ static void defun_internal (int type, int x_p) { int base_type; char **defun_args, **scan_args; const char *category; char *defined_name; char *type_name = NULL; char *type_name2 = NULL; { char *line; /* The @def.. line is the only place in Texinfo where you are allowed to use unquoted braces that don't delimit arguments of a command or a macro; in any other place it will trigger an error message from the reader loop. The special handling of this case inside `args_from_string' is an extra special hack which allows this. The side effect is that if we try to expand the rest of the line below, the recursive reader loop will signal an error if there are brace-delimited arguments on that line. The best solution to this would be to change the syntax of @def.. commands so that it doesn't violate Texinfo's own rules. But it's probably too late for this now, as it will break a lot of existing manuals. Unfortunately, this means that you can't call macros, use @value, etc. inside @def.. commands, sigh. */ get_rest_of_line (0, &line); /* Basic line continuation. If a line ends with \s*@\s* concatanate the next line. */ { char *next_line, *new_line; int i; line_continuation: i = strlen (line) - 1; if (line[i] == '@' && line[i-1] != '@') { get_rest_of_line (0, &next_line); new_line = (char *) xmalloc (i + strlen (next_line) + 2); strncpy (new_line, line, i); new_line[i] = '\0'; free (line); strcat (new_line, " "); strcat (new_line, next_line); line = xstrdup (new_line); free (next_line); free (new_line); goto line_continuation; } } defun_args = (args_from_string (line)); free (line); } scan_args = defun_args; /* Get base type and category string. */ base_type = get_base_type (type); /* xx all these const strings should be determined upon documentlanguage argument and NOT via gettext (kama). */ switch (type) { case defun: case deftypefun: category = _("Function"); break; case defmac: category = _("Macro"); break; case defspec: category = _("Special Form"); break; case defvar: case deftypevar: category = _("Variable"); break; case defopt: category = _("User Option"); break; case defivar: case deftypeivar: category = _("Instance Variable"); break; case defmethod: case deftypemethod: category = _("Method"); break; default: category = next_nonwhite_defun_arg (&scan_args); break; } /* The class name. */ if ((base_type == deftypecv) || (base_type == deftypefn) || (base_type == deftypevr) || (base_type == defcv) || (base_type == defop) || (base_type == deftypeivar) || (base_type == deftypemethod) || (base_type == deftypeop) ) type_name = next_nonwhite_defun_arg (&scan_args); /* The type name for typed languages. */ if ((base_type == deftypecv) || (base_type == deftypeivar) || (base_type == deftypemethod) || (base_type == deftypeop) ) type_name2 = next_nonwhite_defun_arg (&scan_args); /* The function or whatever that's actually being defined. */ defined_name = next_nonwhite_defun_arg (&scan_args); /* This hack exists solely for the purposes of formatting the Texinfo manual. I couldn't think of a better way. The token might be a simple @@ followed immediately by more text. If this is the case, then the next defun arg is part of this one, and we should concatenate them. */ if (*scan_args && **scan_args && !whitespace (**scan_args) && STREQ (defined_name, "@@")) { char *tem = xmalloc (3 + strlen (scan_args[0])); sprintf (tem, "@@%s", scan_args[0]); free (scan_args[0]); scan_args[0] = tem; scan_args++; defined_name = tem; } /* It's easy to write @defun foo(arg1 arg2), but a following ( is misparsed by texinfo.tex and this is next to impossible to fix. Warn about it. */ if (*scan_args && **scan_args && **scan_args == '(') warning ("`%c' follows defined name `%s' instead of whitespace", **scan_args, defined_name); if (!x_p) begin_insertion (type); /* Write the definition header line. This should start at the normal indentation. */ current_indent -= default_indentation_increment; start_paragraph (); if (!html && !xml) switch (base_type) { case deffn: case defvr: case deftp: execute_string (" --- %s: %s", category, defined_name); break; case deftypefn: case deftypevr: execute_string (" --- %s: %s %s", category, type_name, defined_name); break; case defcv: execute_string (" --- %s %s %s: %s", category, _("of"), type_name, defined_name); break; case deftypecv: case deftypeivar: execute_string (" --- %s %s %s: %s %s", category, _("of"), type_name, type_name2, defined_name); break; case defop: execute_string (" --- %s %s %s: %s", category, _("on"), type_name, defined_name); break; case deftypeop: execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name, type_name2, defined_name); break; case deftypemethod: execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name, type_name2, defined_name); break; } else if (html) { /* If this is not a @def...x version, it could only be a normal version @def.... So start the table here. */ if (!x_p) insert_string ("<div class=\"defun\">\n"); else rollback_empty_tag ("blockquote"); /* xx The single words (on, off) used here, should depend on documentlanguage and NOT on gettext --kama. */ switch (base_type) { case deffn: case defvr: case deftp: case deftypefn: case deftypevr: execute_string ("--- %s: ", category); break; case defcv: case deftypecv: case deftypeivar: execute_string ("--- %s %s %s: ", category, _("of"), type_name); break; case defop: case deftypemethod: case deftypeop: execute_string ("--- %s %s %s: ", category, _("on"), type_name); break; } /* switch (base_type)... */ switch (base_type) { case deffn: case defvr: case deftp: /* <var> is for the following function arguments. */ insert_html_tag (START, "b"); execute_string ("%s", defined_name); insert_html_tag (END, "b"); insert_html_tag (START, "var"); break; case deftypefn: case deftypevr: execute_string ("%s ", type_name); insert_html_tag (START, "b"); execute_string ("%s", defined_name); insert_html_tag (END, "b"); insert_html_tag (START, "var"); break; case defcv: case defop: insert_html_tag (START, "b"); execute_string ("%s", defined_name); insert_html_tag (END, "b"); insert_html_tag (START, "var"); break; case deftypecv: case deftypeivar: case deftypemethod: case deftypeop: execute_string ("%s ", type_name2); insert_html_tag (START, "b"); execute_string ("%s", defined_name); insert_html_tag (END, "b"); insert_html_tag (START, "var"); break; } } else if (xml) xml_begin_def_term (base_type, category, defined_name, type_name, type_name2); current_indent += default_indentation_increment; /* Now process the function arguments, if any. If these carry onto the next line, they should be indented by two increments to distinguish them from the body of the definition, which is indented by one increment. */ current_indent += default_indentation_increment; switch (base_type) { case deffn: case defop: process_defun_args (scan_args, 1); break; /* Through Makeinfo 1.67 we processed remaining args only for deftp, deftypefn, and deftypemethod. But the libc manual, for example, needs to say: @deftypevar {char *} tzname[2] And simply allowing the extra text seems far simpler than trying to invent yet more defn commands. In any case, we should either output it or give an error, not silently ignore it. */ default: process_defun_args (scan_args, 0); break; } current_indent -= default_indentation_increment; if (!html) close_single_paragraph (); /* Make an entry in the appropriate index. (XML and Docbook already got their entries, so skip them.) */ if (!xml) switch (base_type) { case deffn: case deftypefn: execute_string ("@findex %s\n", defined_name); break; case defcv: case deftypecv: case deftypevr: case defvr: execute_string ("@vindex %s\n", defined_name); break; case deftypeivar: execute_string ("@vindex %s %s %s\n", defined_name, _("of"), type_name); break; case defop: case deftypeop: case deftypemethod: execute_string ("@findex %s %s %s\n", defined_name, _("on"), type_name); break; case deftp: execute_string ("@tindex %s\n", defined_name); break; } if (xml) xml_end_def_term (); else if (html) { inhibit_paragraph_indentation = 1; no_indent = 1; insert_html_tag (END, "var"); insert_string ("<br>\n"); /* Indent the definition a bit. */ add_html_block_elt ("<blockquote>"); no_indent = 0; inhibit_paragraph_indentation = 0; paragraph_is_open = 0; } /* Deallocate the token list. */ scan_args = defun_args; while (1) { char * arg = (*scan_args++); if (arg == NULL) break; free (arg); } free (defun_args); }