Back to index

tetex-bin  3.0
Classes | Typedefs | Functions | Variables
html.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hstack

Typedefs

typedef struct hstack HSTACK

Functions

void html_output_head (void)
char * escape_string (char *)
void insert_html_tag (int start_or_end, char *tag)
void add_link (char *nodename, char *attributes)
void add_escaped_anchor_name (char *name, int old)
void add_anchor_name (char *nodename, int href)
void add_url_name (char *nodename, int href)
void add_nodename_to_filename (char *nodename, int href)
char * nodename_to_filename (char *nodename)
int rollback_empty_tag (char *tag)
void insert_html_tag_with_attribute ()

Variables

int html_output_head_p
int html_title_written

Class Documentation

struct hstack

Definition at line 24 of file html.h.

Collaboration diagram for hstack:
Class Members
char * attribs
struct hstack * next
char * tag

Typedef Documentation

typedef struct hstack HSTACK

Function Documentation

void add_anchor_name ( char *  nodename,
int  href 
)

Definition at line 644 of file html.c.

{
  if (href > 0)
    {
      if (splitting)
       add_url_name (nodename, href);
      add_char ('#');
    }
  /* Always add NODENAME, so that the reference would pinpoint the
     exact node on its file.  This is so several nodes could share the
     same file, in case of file-name clashes, but also for more
     accurate browser positioning.  */
  if (strcasecmp (nodename, "(dir)") == 0)
    /* Strip the parens, but keep the original letter-case.  */
    add_word_args ("%.3s", nodename + 1);
  else if (strcasecmp (nodename, "top") == 0)
    add_word ("Top");
  else
    add_escaped_anchor_name (nodename, href < 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_escaped_anchor_name ( char *  name,
int  old 
)

Definition at line 604 of file html.c.

{
  canon_white (name);

  if (!old && !strchr ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
                       *name))
    { /* XHTML does not allow anything but an ASCII letter to start an
         identifier.  Therefore kludge in this constant string if we
         have a nonletter.  */
      add_word ("g_t");
    }

  for (; *name; name++)
    {
      if (cr_or_whitespace (*name))
        add_char ('-');

      else if (!old && !URL_SAFE_CHAR (*name))
        /* Cast so characters with the high bit set are treated as >128,
           for example o-umlaut should be 246, not -10.  */
        add_word_args ("_00%x", (unsigned char) *name);

      else if (old && !URL_SAFE_CHAR (*name) && !OLD_URL_SAFE_CHAR (*name))
        /* Different output convention, but still cast as above.  */
        add_word_args ("%%%x", (unsigned char) *name);

      else
        add_char (*name);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_link ( char *  nodename,
char *  attributes 
)

Definition at line 581 of file html.c.

{
  if (nodename)
    {
      add_html_elt ("<link ");
      add_word_args ("%s", attributes);
      add_word_args (" href=\"");
      add_anchor_name (nodename, 1);
      add_word_args ("\" title=\"%s\">\n", nodename);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_nodename_to_filename ( char *  nodename,
int  href 
)

Definition at line 808 of file html.c.

{
  /* for now, don't check: always output filename */
  char *filename = nodename_to_filename_1 (nodename, href);
  add_word (filename);
  free (filename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_url_name ( char *  nodename,
int  href 
)

Definition at line 668 of file html.c.

{
    add_nodename_to_filename (nodename, href);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* escape_string ( char *  )

Definition at line 342 of file html.c.

{
  char *newstring;
  int i = 0, newlen = 0;

  do
    {
      /* Find how much to allocate. */
      switch (string[i])
        {
        case '"':
          newlen += 6;          /* `&quot;' */
          break;
        case '&':
          newlen += 5;          /* `&amp;' */
          break;
        case '<':
        case '>':
          newlen += 4;          /* `&lt;', `&gt;' */
          break;
        default:
          newlen++;
        }
    }
  while (string[i++]);

  if (newlen == i) return string; /* Already OK. */

  newstring = xmalloc (newlen);
  i = 0;
  do
    {
      switch (string[i])
        {
        case '"':
          strcpy (newstring, "&quot;");
          newstring += 6;
          break;
        case '&':
          strcpy (newstring, "&amp;");
          newstring += 5;
          break;
        case '<':
          strcpy (newstring, "&lt;");
          newstring += 4;
          break;
        case '>':
          strcpy (newstring, "&gt;");
          newstring += 4;
          break;
        default:
          newstring[0] = string[i];
          newstring++;
        }
    }
  while (string[i++]);
  free (string);
  return newstring - newlen;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 193 of file html.c.

{
  static const char *html_title = NULL;
  char *encoding;

  if (html_output_head_p)
    return;
  html_output_head_p = 1;

  encoding = current_document_encoding ();

  /* The <title> should not have markup, so use text_expansion.  */
  if (!html_title)
    html_title = escape_string (title ?
        text_expansion (title) : (char *) _("Untitled"));

  /* Make sure this is the very first string of the output document.  */
  output_paragraph_offset = 0;

  add_html_block_elt_args ("<html lang=\"%s\">\n<head>\n",
      language_table[language_code].abbrev);

  /* When splitting, add current node's name to title if it's available and not
     Top.  */
  if (splitting && current_node && !STREQ (current_node, "Top"))
    add_word_args ("<title>%s - %s</title>\n",
        escape_string (xstrdup (current_node)), html_title);
  else
    add_word_args ("<title>%s</title>\n",  html_title);

  add_word ("<meta http-equiv=\"Content-Type\" content=\"text/html");
  if (encoding && *encoding)
    add_word_args ("; charset=%s", encoding);
                   
  add_word ("\">\n");

  if (!document_description)
    document_description = html_title;

  add_word_args ("<meta name=\"description\" content=\"%s\">\n",
                 document_description);
  add_word_args ("<meta name=\"generator\" content=\"makeinfo %s\">\n",
                 VERSION);

  /* Navigation bar links.  */
  if (!splitting)
    add_word ("<link title=\"Top\" rel=\"top\" href=\"#Top\">\n");
  else if (tag_table)
    {
      /* Always put a top link.  */
      add_word ("<link title=\"Top\" rel=\"start\" href=\"index.html#Top\">\n");

      /* We already have a top link, avoid duplication.  */
      if (tag_table->up && !STREQ (tag_table->up, "Top"))
        add_link (tag_table->up, "rel=\"up\"");

      if (tag_table->prev)
        add_link (tag_table->prev, "rel=\"prev\"");

      if (tag_table->next)
        add_link (tag_table->next, "rel=\"next\"");

      /* fixxme: Look for a way to put links to various indices in the
         document.  Also possible candidates to be added here are First and
         Last links.  */
    }
  else
    {
      /* We are splitting, but we neither have a tag_table.  So this must be
         index.html.  So put a link to Top. */
      add_word ("<link title=\"Top\" rel=\"start\" href=\"#Top\">\n");
    }

  add_word ("<link href=\"http://www.gnu.org/software/texinfo/\" \
rel=\"generator-home\" title=\"Texinfo Homepage\">\n");

  if (copying_text)
    { /* It is not ideal that we include the html markup here within
         <head>, so we use text_expansion.  */
      insert_string ("<!--\n");
      insert_string (text_expansion (copying_text));
      insert_string ("-->\n");
    }

  /* Put the style definitions in a comment for the sake of browsers
     that don't support <style>.  */
  add_word ("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n");
  add_word ("<style type=\"text/css\"><!--\n");

  {
    char *css_inline = NULL;

    if (css_include)
      /* This writes out any @import commands from the --css-file,
         and returns any actual css code following the imports.  */
      css_inline = process_css_file (css_include);

    /* This seems cleaner than adding <br>'s at the end of each line for
       these "roman" displays.  It's hardly the end of the world if the
       browser doesn't do <style>s, in any case; they'll just come out in
       typewriter.  */
#define CSS_FONT_INHERIT "font-family:inherit"
    add_word_args ("  pre.display { %s }\n", CSS_FONT_INHERIT);
    add_word_args ("  pre.format  { %s }\n", CSS_FONT_INHERIT);

    /* Alternatively, we could do <font size=-1> in insertion.c, but this
       way makes it easier to override.  */
#define CSS_FONT_SMALLER "font-size:smaller"
    add_word_args ("  pre.smalldisplay { %s; %s }\n", CSS_FONT_INHERIT,
                   CSS_FONT_SMALLER);
    add_word_args ("  pre.smallformat  { %s; %s }\n", CSS_FONT_INHERIT,
                   CSS_FONT_SMALLER);
    add_word_args ("  pre.smallexample { %s }\n", CSS_FONT_SMALLER);
    add_word_args ("  pre.smalllisp    { %s }\n", CSS_FONT_SMALLER);

    /* Since HTML doesn't have a sc element, we use span with a bit of
       CSS spice instead.  */
#define CSS_FONT_SMALL_CAPS "font-variant:small-caps"
    add_word_args ("  span.sc    { %s }\n", CSS_FONT_SMALL_CAPS);

    /* Roman (default) font class, closest we can come.  */
#define CSS_FONT_ROMAN "font-family:serif; font-weight:normal;"
    add_word_args ("  span.roman { %s } \n", CSS_FONT_ROMAN);

    /* Sans serif font class.  */
#define CSS_FONT_SANSSERIF "font-family:sans-serif; font-weight:normal;"
    add_word_args ("  span.sansserif { %s } \n", CSS_FONT_SANSSERIF);

    /* Write out any css code from the user's --css-file.  */
    if (css_inline)
      insert_string (css_inline);

    add_word ("--></style>\n");
  }

  add_word ("</head>\n<body>\n");

  if (title && !html_title_written && titlepage_cmd_present)
    {
      add_word_args ("<h1 class=\"settitle\">%s</h1>\n", html_title);
      html_title_written = 1;
    }

  free (encoding);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void insert_html_tag ( int  start_or_end,
char *  tag 
)

Definition at line 573 of file html.c.

{
  insert_html_tag_with_attribute (start_or_end, tag, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* nodename_to_filename ( char *  nodename)

Definition at line 817 of file html.c.

{
  /* The callers of nodename_to_filename use the result to produce
     <a href=, so call nodename_to_filename_1 with last arg non-zero.  */
  return nodename_to_filename_1 (nodename, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int rollback_empty_tag ( char *  tag)

Definition at line 435 of file html.c.

{
  int check_position = output_paragraph_offset;
  int taglen = strlen (tag);
  int rollback_happened = 0;
  char *contents = "";
  char *contents_canon_white = "";

  /* If output_paragraph is empty, we cannot rollback :-\  */
  if (output_paragraph_offset <= 0)
    return 0;

  /* Find the end of the previous tag.  */
  while (output_paragraph[check_position-1] != '>' && check_position > 0)
    check_position--;

  /* Save stuff between tag's end to output_paragraph's end.  */
  if (check_position != output_paragraph_offset)
    {
      contents = xmalloc (output_paragraph_offset - check_position + 1);
      memcpy (contents, output_paragraph + check_position,
          output_paragraph_offset - check_position);

      contents[output_paragraph_offset - check_position] = '\0';

      contents_canon_white = xstrdup (contents);
      canon_white (contents_canon_white);
    }

  /* Find the start of the previous tag.  */
  while (output_paragraph[check_position-1] != '<' && check_position > 0)
    check_position--;

  /* Check to see if this is the tag.  */
  if (strncmp ((char *) output_paragraph + check_position, tag, taglen) == 0
      && (whitespace (output_paragraph[check_position + taglen])
          || output_paragraph[check_position + taglen] == '>'))
    {
      if (!contents_canon_white || !*contents_canon_white)
        {
          /* Empty content after whitespace removal, so roll it back.  */
          output_paragraph_offset = check_position - 1;
          rollback_happened = 1;

          /* Original contents may not be empty (whitespace.)  */
          if (contents && *contents)
            {
              insert_string (contents);
              free (contents);
            }
        }
    }

  return rollback_happened;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 189 of file html.c.

Definition at line 190 of file html.c.