bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for docboook to not generate index


From: Per Bothner
Subject: patch for docboook to not generate index
Date: Fri, 05 Aug 2005 15:20:26 -0700
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720)

As discussed before, docbook processors (at least the most popular xslt stylesheets) do their own index processing, and it doesn't really make sense for this to be done by makeinfo. This patch changes makeinfo to just emit a content-free <index> tag for a @printindex, leaving to the docbook processor to do the actual formatting.
--
        --Per Bothner
address@hidden   http://per.bothner.com/
2005-08-05  Per Bothner  <address@hidden>

        * makeinfo/index.c (cm_printindex): Don't xml_insert_indexentry if
        docbook, since we'll let the doxbook processor generate the index.
        * makeinfo/xml.h (xml_sort_index, xml_insert_indexentry): Remove.
        * makeinfo/xml.c (xml_begin_index): Don't actually do any formatting.
        (xml_end_index):  Don't do anything except close <index>.
        (xml_insert_indexentry): Remove no-longer-used function.

        * makeinfo/xml.c (element docbook_element_list): The docbook <index>
        element should *not* be contained_in_para.
        
        * makeinfo/xml.c (xml_begin_document): Add id attribute to top-level
        book if emitting docbook.

Index: makeinfo/index.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/index.c,v
retrieving revision 1.18
diff -p -u -r1.18 index.c
--- makeinfo/index.c    15 May 2005 00:00:07 -0000      1.18
+++ makeinfo/index.c    5 Aug 2005 22:14:33 -0000
@@ -869,11 +869,7 @@ cm_printindex (void)
             }
           else if (xml && docbook)
             {
-              /* In the DocBook case, the expanded index entry is not
-                 good for us, since it was expanded for non-DocBook mode
-                 inside sort_index.  So we send the original entry text
-                 to be used with execute_string.  */
-              xml_insert_indexentry (index->entry_text, index_node);
+             /* Let DocBook processor generate the index. */
             }
           else
             {
Index: makeinfo/xml.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/xml.c,v
retrieving revision 1.60
diff -p -u -r1.60 xml.c
--- makeinfo/xml.c      15 May 2005 00:00:08 -0000      1.60
+++ makeinfo/xml.c      5 Aug 2005 22:14:33 -0000
@@ -32,9 +32,6 @@
 
 #include <assert.h>
 
-/* Options */
-int xml_index_divisions = 1;
-
 #if !__OPTIMIZE__
 /* To make enum names available to debugger. */
 static enum xml_element xml_element_dummy;
@@ -415,7 +412,7 @@ element docbook_element_list [] = {
   { "example",             1, 1, 0 },
   { "sidebar",             1, 0, 0 },
 
-  { "index",               0, 1, 0 }, /* PRINTINDEX */
+  { "index",               0, 0, 0 }, /* PRINTINDEX */
   { "",                    0, 1, 0 }, /* LISTOFFLOATS */
   { "",                    0, 1, 0 }, /* ANCHOR */
 
@@ -536,6 +533,8 @@ int xml_no_indent = 0;
 
 int xml_no_para = 0;
 char *xml_node_id = NULL;
+
+/* Currently sorting the index. */
 int xml_sort_index = 0;
 
 int xml_in_xref_token = 0;
@@ -656,7 +655,9 @@ xml_begin_document (char *output_filenam
   if (language_code != last_language_code)
     {
       if (docbook)
-        xml_insert_element_with_attribute (TEXINFO, START, "lang=\"%s\"", 
language_table[language_code].abbrev);
+       /* The toplevel <book> element needs an id attribute if you want to use
+          the chunk.xml feature of the DocBook-XSL stylesheets. */
+        xml_insert_element_with_attribute (TEXINFO, START, "id=\"book-root\" 
lang=\"%s\"", language_table[language_code].abbrev);
       else
        xml_insert_element_with_attribute (TEXINFO, START, "xml:lang=\"%s\"", 
language_table[language_code].abbrev);
     }
@@ -810,7 +811,7 @@ xml_insert_element_with_attribute (elt, 
   /* Look at the replace_elements table to see if we have to change the 
element */
   if (xml_sort_index)
       return;
-  if (docbook)
+  if (docbook && element_stack_index > 0)
     {
       replace_element *element_list = replace_elements;
       while (element_list->element_to_replace >= 0)
@@ -1798,94 +1799,16 @@ xml_close_indexentry (void)
 void
 xml_begin_index (void)
 {
-  typedef struct xml_index_title {
-      struct xml_index_title *next;
-      char *title;
-  } XML_INDEX_TITLE;
-
-  static XML_INDEX_TITLE *xml_index_titles = NULL;
-
-  if (!handling_delayed_writes)
-    { /* We assume that we just opened a section, and so that the last output 
is
-         <SECTION ID="node-name"><TITLE>Title</TITLE>
-         where SECTION can be CHAPTER, ...  */
-
-      XML_INDEX_TITLE *new = xmalloc (sizeof (XML_INDEX_TITLE));
-      xml_section *temp = last_section;
-
-      int l = output_paragraph_offset-xml_last_section_output_position;
-      char *tmp = xmalloc (l+1);
-      char *p = tmp;
-      strncpy (tmp, (char *) output_paragraph, l);
-
-      /* We remove <SECTION */
-      tmp[l] = '\0';
-      while (*p != '<')
-        p++;
-      while (*p != ' ')
-        p++;
-      /* ... and its label attribute.  */
-      if (strncmp (p, " label=", 7) == 0)
-        {
-          p++;
-          while (*p != ' ')
-            p++;
-        }
-
-      output_paragraph_offset = xml_last_section_output_position;
-      xml_last_section_output_position = 0;
-
-      xml_pop_current_element (); /* remove section element from elements 
stack */
-
-      if (last_section)
-        last_section = last_section->prev; /* remove section from sections 
stack */
-      if (temp)
-        {
-          free (temp->name);
-          free (temp);
-        }
-
-      new->title = xstrdup (p);
-      new->next = xml_index_titles;
-      xml_index_titles = new;
-    }
-  else
+  if (handling_delayed_writes)
     {
-      static int xml_index_titles_reversed = 0;
-
-      if (!xml_index_titles_reversed)
-        {
-          xml_index_titles = (XML_INDEX_TITLE *) reverse_list
-            ((GENERIC_LIST *) xml_index_titles);
-          xml_index_titles_reversed = 1;
-        }
-
       /* We put <INDEX> */
       xml_insert_element (PRINTINDEX, START);
-      if (xml_index_titles)
-        {
-          /* Remove the final > */
-          output_paragraph_offset--;
-          /* and put  ID="node-name"><TITLE>Title</TITLE> */
-          insert_string (xml_index_titles->title);
-          free (xml_index_titles->title);
-          xml_index_titles = xml_index_titles->next;
-        }
-
-      if (xml_index_divisions)
-        {
-          xml_insert_element (INDEXDIV, START);
-          indexdivempty = 1;
-        }
     }
 }
 
 void
 xml_end_index (void)
 {
-  xml_close_indexentry ();
-  if (xml_index_divisions)
-    xml_insert_element (INDEXDIV, END);
   xml_insert_element (PRINTINDEX, END);
 }
 
@@ -1911,75 +1834,6 @@ xml_index_divide (char *entry)
       insert (toupper (c));
       xml_insert_element (TITLE, END);
     }
-}
-
-void
-xml_insert_indexentry (char *entry, char *node)
-{
-  char *primary = NULL, *secondary;
-  if (xml_index_divisions)
-    xml_index_divide (entry);
-
-  indexdivempty = 0;
-  if (strstr (entry+1, INDEX_SEP))
-    {
-      primary = xmalloc (strlen (entry) + 1);
-      strcpy (primary, entry);
-      secondary = strstr (primary+1, INDEX_SEP);
-      *secondary = '\0';
-      secondary += strlen (INDEX_SEP);
-
-      if (in_secondary && strcmp (primary, index_primary) == 0)
-        {
-          xml_insert_element (SECONDARYIE, END);
-          xml_insert_element (SECONDARYIE, START);
-          execute_string ("%s", secondary);
-        }
-      else
-        {
-          xml_close_indexentry ();
-          xml_insert_element (INDEXENTRY, START);
-          in_indexentry = 1;
-          xml_insert_element (PRIMARYIE, START);
-          execute_string ("%s", primary);
-          xml_insert_element (PRIMARYIE, END);
-          xml_insert_element (SECONDARYIE, START);
-          execute_string ("%s", secondary);
-          in_secondary = 1;
-        }
-    }
-  else
-    {
-      xml_close_indexentry ();
-      xml_insert_element (INDEXENTRY, START);
-      in_indexentry = 1;
-      xml_insert_element (PRIMARYIE, START);
-      execute_string ("%s", entry);
-    }
-  add_word (", ");
-
-  /* Don't link to @unnumbered sections directly.
-     We are disabling warnings temporarily, otherwise these xrefs
-     will cause bogus warnings about missing punctuation.  */
-  {
-    extern int print_warnings;
-    int save_print_warnings = print_warnings;
-    print_warnings = 0;
-    execute_string ("%cxref{%s}", COMMAND_PREFIX, xstrdup (node));
-    print_warnings = save_print_warnings;
-  }
-
-  if (primary)
-    {
-      strcpy (index_primary, primary);
-      /*      xml_insert_element (SECONDARYIE, END);*/
-      /*     *(secondary-1) = ',';*/ /* necessary ? */
-      free (primary);
-    }
-  else
-    xml_insert_element (PRIMARYIE, END);
-
-  /*  xml_insert_element (INDEXENTRY, END); */
 }
 
 void
Index: makeinfo/xml.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/xml.h,v
retrieving revision 1.26
diff -p -u -r1.26 xml.h
--- makeinfo/xml.h      15 May 2005 00:00:08 -0000      1.26
+++ makeinfo/xml.h      5 Aug 2005 22:14:33 -0000
@@ -22,12 +22,11 @@
 #ifndef XML_H
 #define XML_H
 
-/* Options. */
-
-/* Separate index entries into divisions for each letters. */
-extern int xml_index_divisions;
+/* Currently sorting the index. */
 extern int xml_sort_index;
 
+/* Options. */
+
 extern int xml_no_indent;
 
 extern int xml_node_open;
@@ -110,7 +109,6 @@ extern void xml_add_char (int character)
   xml_insert_entity (char *entity_name),
   xml_insert_footnote (char *note),
   xml_insert_quotation (char *type, int arg),
-  xml_insert_indexentry (char *entry, char *node),
   xml_insert_indexterm (char *indexterm, char *index),
   xml_insert_docbook_image (char *name_arg),
   xml_synindex (char *from, char *to),

reply via email to

[Prev in Thread] Current Thread [Next in Thread]