Below is a patch to change some of makeinfo's behavior when outputting
html:

* use <div> for flushleft and flushright. currently makeinfo does
  nothing special for these commands.

* two new optional arguments to the @image command:

-- text for the alt attribute, defaults to the current behavior of the
filename of the image file.

-- extension of the image file. allowing for future expansion in
   browsers. defaults to the current behavior of searching for .png
   then .jpg

* when writing a short contents, the links in the short contents point
  to the "long" contents rather than the full document.

* add an explicit <br> before outputting a <pre> tag.

hope this is useful,

--Will

1999-11-26 W. L. Estes <[EMAIL PROTECTED]>

        * makeinfo/insertion.c (begin_insertion): add an explicit <br>
        before beginning a <pre> block. for flushleft and flushright, use
        <div> tag with an align attribute set.
        * makeinfo/insertion.c (end_insertion): for flushleft and
        flushright, end the </div> block.

        * makeinfo/makeinfo.c (cm_image): new variable, alt_arg now allows
        user-supplied alt attribute value and
        ext_arg allows user-supplied extension for image files.

        * makeinfo/toc.c (contents_update_html): add anchors at chapter
        level entries
        (shortcontents_update_html): hrefs in shortcontents point to the
        above anchors in the detailed contents

        * doc/texinfo.txi: document changes to @image and the new behavior
        of shortcontents entries

diff -urpw texinfo-4.0.orig/makeinfo texinfo-4.0/makeinfo
diff -urpw texinfo-4.0.orig/makeinfo/insertion.c texinfo-4.0/makeinfo/insertion.c
--- texinfo-4.0.orig/makeinfo/insertion.c       Mon Jul 19 17:37:36 1999
+++ texinfo-4.0/makeinfo/insertion.c    Thu Nov 25 08:28:26 1999
@@ -443,7 +443,7 @@ begin_insertion (type)
         /* Kludge alert: if <pre> is followed by a newline, IE3
            renders an extra blank line before the pre-formatted block.
            Other browsers seem to not mind one way or the other.  */
-        add_word ("<pre>");
+        add_word ("<br><pre>");
 
       if (type != format && type != smallformat)
         current_indent += default_indentation_increment;
@@ -581,6 +581,8 @@ begin_insertion (type)
       close_single_paragraph ();
       inhibit_paragraph_indentation = 1;
       filling_enabled = indented_fill = no_indent = 0;
+      if (html)
+       add_word ("<div align=\"left\">");
       break;
 
     case flushright:
@@ -588,6 +590,8 @@ begin_insertion (type)
       filling_enabled = indented_fill = no_indent = 0;
       inhibit_paragraph_indentation = 1;
       force_flush_right++;
+      if (html)
+       add_word ("<div align=\"right\">");
       break;
 
     default:
@@ -680,6 +684,11 @@ end_insertion (type)
       break;
 
     case flushleft:
+      if (html)
+       add_word ("</div>\n");
+      close_insertion_paragraph ();
+      break;
+
     case group:
     case cartouche:
       close_insertion_paragraph ();
@@ -724,6 +733,8 @@ end_insertion (type)
 
     case flushright:
       force_flush_right--;
+      if (html)
+       add_word ("</div>\n");
       close_insertion_paragraph ();
       break;
 
diff -urpw texinfo-4.0.orig/makeinfo/makeinfo.c texinfo-4.0/makeinfo/makeinfo.c
--- texinfo-4.0.orig/makeinfo/makeinfo.c        Thu Nov 25 12:28:10 1999
+++ texinfo-4.0/makeinfo/makeinfo.c     Thu Nov 25 12:46:21 1999
@@ -3008,13 +3008,13 @@ void
 cm_image (arg)
      int arg;
 {
-  char *name_arg, *rest;
+  char *name_arg, *rest, *alt_arg, *ext_arg;
 
   if (arg == END)
     return;
 
   name_arg = get_xref_token (1); /* expands all macros in image */
-  /* We don't (yet) care about any other args, but read them so they
+  /* We don't (yet) care about the next two args, but read them so they
      don't end up in the text.  */
   rest = get_xref_token (0);
   if (rest)
@@ -3022,25 +3022,39 @@ cm_image (arg)
   rest = get_xref_token (0);
   if (rest)
     free (rest);
+  alt_arg = get_xref_token (1); /* expands all macros in alt text */
+  ext_arg = get_xref_token (0);
 
   if (*name_arg)
     {
-      char *fullname = xmalloc (strlen (name_arg) + 4 + 1);
+      char *fullname = xmalloc (strlen (name_arg) + ((ext_arg)?strlen(ext_arg)+1:4) + 
+1);
 
       if (html)
-        { /* fixxme It would be nice to insert more useful alt text.  */
+        {
+         if (*ext_arg)
+           {
+             sprintf (fullname, "%s.%s", name_arg, ext_arg);
+             if (access (fullname, R_OK) != 0)
+               {
+                 line_error (_("%s' argument to @image command not found"), fullname);
+                 return;
+               }
+           }
+         else
+           {
           sprintf (fullname, "%s.png", name_arg);
           if (access (fullname, R_OK) != 0)
             {
               sprintf (fullname, "%s.jpg", name_arg);
               if (access (fullname, R_OK) != 0)
                 {
-                  line_error (_("No .png or .jpg for `%s'"), name_arg);
+                  line_error (_("No .png or .jpg for `%s' and no extension 
+supplied"), name_arg);
                   return;
                 }
           }
+           }
 
-          add_word_args ("<img src=\"%s\" alt=\"%s\">", fullname, fullname);
+          add_word_args ("<img src=\"%s\" alt=\"%s\">", fullname, 
+(*alt_arg)?alt_arg:fullname);
         }
       else
         { /* Try to open foo.txt.  */
@@ -3083,6 +3097,10 @@ cm_image (arg)
 
   if (name_arg)
     free (name_arg);
+  if (alt_arg)
+    free (alt_arg);
+  if (ext_arg)
+    free (ext_arg);
 }
 
 /* Conditionals.  */
diff -urpw texinfo-4.0.orig/makeinfo/toc.c texinfo-4.0/makeinfo/toc.c
--- texinfo-4.0.orig/makeinfo/toc.c     Thu Nov 25 12:28:08 1999
+++ texinfo-4.0/makeinfo/toc.c  Fri Nov 26 15:00:05 1999
@@ -231,6 +231,16 @@ contents_update_html (fp)
             fputs ("</ul>\n", fp);
         }
 
+      if (toc_entry_alist[i]->level == 0)
+       {
+         size_t anchor_size = strlen(toc_entry_alist[i]->name) - strlen 
+(strchr(toc_entry_alist[i]->name,'>'))+1;
+          char *just_toc = xmalloc (anchor_size*sizeof (char));
+
+         strncpy (just_toc, toc_entry_alist[i]->name, anchor_size);
+         just_toc[anchor_size] = '\0';
+         fprintf (fp, "<a name=\"toc_%s</a>\n", just_toc);
+         free (just_toc);
+       }
       fprintf (fp, "<li><a href=\"#%s</a>\n", toc_entry_alist[i]->name);
 
       last_level = toc_entry_alist[i]->level;
@@ -295,8 +305,7 @@ shortcontents_update_html (fp)
     {
       if ((toc_entry_alist[i])->level == 0)
         {
-          fputs ("<li>", fp);
-          fprintf (fp, "<a href=\"#%s\n", toc_entry_alist[i]->name);
+          fprintf (fp, "<li><a href=\"#toc_%s</a>\n", toc_entry_alist[i]->name);
         }
     }
 



        --- texinfo-4.0.orig/doc/texinfo.txi    Thu Nov 25 12:28:09 1999
+++ texinfo-4.0/doc/texinfo.txi Fri Nov 26 11:09:28 1999
@@ -3875,7 +3875,14 @@ sectioning command such as @code{@@unnum
 
 Since an Info file uses menus instead of tables of contents, the Info
 formatting commands ignore the contents commands.  But the contents are
-included in plain text output (generated by @code{makeinfo --no-headers}).
+included in plain text output (generated by @code{makeinfo
+--no-headers}) unless @code{makeinfo} is writing its output to standard output.
+
+When @code{makeinfo} writes a short table of contents while producing
+html output, the hyperlinks in the short table of contents point to
+corresponding entries in the full table of contents rather than the text
+of the document. The hyperlinks in the full table of contents do,
+however, point to the main text of the document.
 
 The contents commands can be placed either at the very end of the file,
 after any indices (see the previous section) and just before the
@@ -3885,8 +3892,7 @@ the former is that then the contents out
 because it reflects the processing just done.  The advantage to the
 latter is that the contents are printed in the proper place, thus you do
 not need to rearrange the DVI file with @command{dviselect} or shuffle
-paper.  However, contents commands at the beginning of the document are
-ignored when outputting to standard output.
+paper.
 
 @findex setcontentsaftertitlepage
 @findex setshortcontentsaftertitlepage
@@ -9977,7 +9983,7 @@ You can insert an image given in an exte
 @code{@@image} command:
 
 @example
-@@image@{@var{filename}, @r{[}@var{width}@r{]}, @r{[}@var{height}@r{]}@}
+@@image@{@var{filename}, @r{[}@var{width}@r{]}, @r{[}@var{height}@r{]}, 
+@r{[}@var{alttext}@r{]}, @r{[}@var{extension}@r{]}@}
 @end example
 
 @cindex Formats for images
@@ -9998,10 +10004,24 @@ Info output (more or less as if it was a
 @cindex GIF, unsupported due to patents
 @cindex PNG image format
 @cindex JPEG image format
-@code{makeinfo} producing HTML output tries @file{@var{filename}.png};
+@cindex JPG image format
+@pindex foo.xpm
+If you supply the optional fifth argument to @code{@@image},
+@code{makeinfo}, when producing html output, tries to open the file you
+specified with the extension that you supplied:
+
+@example
+@@image@{foo,,,,xpm@}
+@end example
+
+@noindent
+will cause @code{makeinfo} to try @file{foo.xpm}.
+
+If you do not supply the optional fifth argument,
+@code{makeinfo}, when producing HTML output, tries @file{@var{filename}.png};
 if that does not exist, it tries @file{@var{filename}.jpg}.  If that
-does not exist either, it complains.  (We cannot support GIF format due
-to patents.)
+does not exist either, it complains.  (We cannot support GIF format
+directly due to patents.)
 @end itemize
 
 @cindex Width of images
@@ -10070,6 +10090,14 @@ figures.  Therefore, if you intend it to
 a blank line before the command, or the output will run into the
 preceding text.
 
+@cindex alt attribute for images
+@cindex alternate text for images
+When producing html output, @code{makeinfo} sets the @dfn{alt attribute}
+for inline images. Supplying the fourth optional argument to the
+@code{@@image} command causes @code{makeinfo} to use that text for the
+value of the alt attribute. Omitting the fourth optional argument causes
+@code{makeinfo} to supply the full name of the file that contains the
+image being displayed as the value of the alt attribute.
 
 @node Breaks
 @chapter Making and Preventing Breaks

Reply via email to