[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lowered/raised sections keep the same css class
From: |
Karl Berry |
Subject: |
Re: lowered/raised sections keep the same css class |
Date: |
Thu, 24 Jul 2003 20:07:05 -0400 |
When @lowersections and @raisesections is used, the css class for a
sectionning element is only based on the sectionning command and not
on the real level.
Thanks for the report, here's a patch (two files are affected). I
suspect there may be more bugs in this area ...
k
*** sectioning.c 14 Jul 2003 13:20:18 -0000 1.11
--- sectioning.c 25 Jul 2003 00:02:24 -0000 1.12
***************
*** 162,171 ****
return -1;
}
! /* Return an integer which identifies the type section present in TEXT. */
int
! what_section (text)
char *text;
{
int index, j;
char *temp;
--- 162,176 ----
return -1;
}
! /* Return an integer which identifies the type of section present in
! TEXT -- 1 for @top, 2 for chapters, ..., 5 for subsubsections (as
! specified in section_alist). We take into account any @lowersections
! and @raisesections. If SECNAME is non-NULL, also return the
! corresponding section name. */
int
! what_section (text, secname)
char *text;
+ char **secname;
{
int index, j;
char *temp;
***************
*** 205,211 ****
if (return_val < 0)
return_val = 0;
else if (return_val > 5)
! return_val = 5;
return return_val;
}
return -1;
--- 210,239 ----
if (return_val < 0)
return_val = 0;
else if (return_val > 5)
! return_val = 5;
!
! if (secname)
! {
! int i;
! int alist_size = sizeof (section_alist) /
sizeof(section_alist_type);
! /* Find location of offset sectioning entry, but don't go off
! either end of the array. */
! int index_offset = MAX (index - section_alist_offset, 0);
! index_offset = MIN (index_offset, alist_size - 1);
!
! /* Also make sure we don't go into the next "group" of
! sectioning changes, e.g., change from an @appendix to an
! @heading or some such. */
! #define SIGN(expr) ((expr) < 0 ? -1 : 1)
! for (i = index; i != index_offset; i -= SIGN (section_alist_offset))
! {
! /* As it happens, each group has unique .num/.toc values. */
! if (section_alist[i].num != section_alist[index_offset].num
! || section_alist[i].toc != section_alist[index_offset].toc)
! break;
! }
! *secname = section_alist[i].name;
! }
return return_val;
}
return -1;
***************
*** 215,235 ****
sectioning_underscore (cmd)
char *cmd;
{
/* If we're not indenting the first paragraph, we shall make it behave
like @noindent is called directly after the section heading. */
if (! do_first_par_indent)
cm_noindent ();
if (xml)
{
- char *temp;
- int level;
- temp = xmalloc (2 + strlen (cmd));
- temp[0] = COMMAND_PREFIX;
- strcpy (&temp[1], cmd);
- level = what_section (temp);
- level -= 2;
- free (temp);
xml_close_sections (level);
/* Mark the beginning of the section
If the next command is printindex, we will remove
--- 243,267 ----
sectioning_underscore (cmd)
char *cmd;
{
+ char *temp, *secname;
+ int level;
+
/* If we're not indenting the first paragraph, we shall make it behave
like @noindent is called directly after the section heading. */
if (! do_first_par_indent)
cm_noindent ();
+ temp = xmalloc (2 + strlen (cmd));
+ temp[0] = COMMAND_PREFIX;
+ strcpy (&temp[1], cmd);
+ level = what_section (temp, &secname);
+ level -= 2;
+ if (level < 0)
+ level = 0;
+ free (temp);
+
if (xml)
{
xml_close_sections (level);
/* Mark the beginning of the section
If the next command is printindex, we will remove
***************
*** 237,280 ****
flush_output ();
xml_last_section_output_position = output_paragraph_offset;
! xml_insert_element (xml_element (cmd), START);
xml_insert_element (TITLE, START);
! xml_open_section (level, cmd);
get_rest_of_line (0, &temp);
execute_string ("%s\n", temp);
free (temp);
xml_insert_element (TITLE, END);
}
else
{
! char character;
! char *temp;
! int level;
!
! temp = xmalloc (2 + strlen (cmd));
! temp[0] = COMMAND_PREFIX;
! strcpy (&temp[1], cmd);
! level = what_section (temp);
! free (temp);
! level -= 2;
!
! if (level < 0)
! level = 0;
!
! if (html)
! sectioning_html (level, cmd);
! else
! {
! character = scoring_characters[level];
! insert_and_underscore (level, character, cmd);
! }
}
}
! /* insert_and_underscore and sectioning_html are the
! only functions which call this.
! I have created this, because it was exactly the same
! code in both functions. */
static char *
handle_enum_increment (level, index)
int level;
--- 269,294 ----
flush_output ();
xml_last_section_output_position = output_paragraph_offset;
! xml_insert_element (xml_element (secname), START);
xml_insert_element (TITLE, START);
! xml_open_section (level, secname);
get_rest_of_line (0, &temp);
execute_string ("%s\n", temp);
free (temp);
xml_insert_element (TITLE, END);
}
+ else if (html)
+ sectioning_html (level, secname);
else
{
! char character = scoring_characters[level];
! insert_and_underscore (level, character, secname);
}
}
!
! /* insert_and_underscore and sectioning_html call this. */
!
static char *
handle_enum_increment (level, index)
int level;
***************
*** 419,428 ****
old_no_indent = no_indent;
no_indent = 1;
! /* level 0 (chapter) is <h2>, everything else is <h3>. We don't want
! to go lower than that because browsers then start rendering the
! headings smaller than the text. */
! add_word_args ("<h%d class=\"%s\">", MIN (3, level + 2), cmd);
/* If we are outside of any node, produce an anchor that
the TOC could refer to. */
--- 433,440 ----
old_no_indent = no_indent;
no_indent = 1;
! /* level 0 (chapter) is <h2>, and we go down from there. */
! add_word_args ("<h%d class=\"%s\">", level + 2, cmd);
/* If we are outside of any node, produce an anchor that
the TOC could refer to. */
***************
*** 483,489 ****
if (outstanding_node)
outstanding_node = 0;
! add_word_args ("</h%d>", MIN (3, level + 2));
close_paragraph();
filling_enabled = 1;
no_indent = old_no_indent;
--- 495,501 ----
if (outstanding_node)
outstanding_node = 0;
! add_word_args ("</h%d>", level + 2);
close_paragraph();
filling_enabled = 1;
no_indent = old_no_indent;
***************
*** 584,590 ****
if (input_text_offset < input_text_length)
input_text_offset++;
! this_section = what_section (input_text + input_text_offset);
/* If we found a sectioning command, then give the top section
a level of this section - 1. */
--- 596,603 ----
if (input_text_offset < input_text_length)
input_text_offset++;
! this_section = what_section (input_text + input_text_offset,
! NULL);
/* If we found a sectioning command, then give the top section
a level of this section - 1. */
*** node.c 1 May 2003 00:30:07 -0000 1.12
--- node.c 25 Jul 2003 00:03:02 -0000 1.13
***************
*** 633,639 ****
/* Check for defaulting of this node's next, prev, and up fields. */
defaulting = (*next == 0 && *prev == 0 && *up == 0);
! this_section = what_section (input_text + input_text_offset);
/* If we are defaulting, then look at the immediately following
sectioning command (error if none) to determine the node's
--- 633,639 ----
/* Check for defaulting of this node's next, prev, and up fields. */
defaulting = (*next == 0 && *prev == 0 && *up == 0);
! this_section = what_section (input_text + input_text_offset, NULL);
/* If we are defaulting, then look at the immediately following
sectioning command (error if none) to determine the node's