diff options
Diffstat (limited to 'contrib/texinfo/makeinfo/html.c')
-rw-r--r-- | contrib/texinfo/makeinfo/html.c | 99 |
1 files changed, 85 insertions, 14 deletions
diff --git a/contrib/texinfo/makeinfo/html.c b/contrib/texinfo/makeinfo/html.c index c03f4f7bfb8c..51960fc17509 100644 --- a/contrib/texinfo/makeinfo/html.c +++ b/contrib/texinfo/makeinfo/html.c @@ -1,7 +1,7 @@ /* html.c -- html-related utilities. - $Id: html.c,v 1.26 2002/03/23 20:39:49 karl Exp $ + $Id: html.c,v 1.8 2002/11/04 22:14:40 karl Exp $ - Copyright (C) 1999, 2000, 01, 02 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,14 +24,16 @@ #include "makeinfo.h" #include "sectioning.h" +HSTACK *htmlstack = NULL; + /* See html.h. */ int html_output_head_p = 0; +int html_title_written = 0; void html_output_head () { static char *html_title = NULL; - static int html_title_written = 0; if (html_output_head_p) return; @@ -53,10 +55,12 @@ html_output_head () if (!document_description) document_description = html_title; - add_word_args ("<meta name=description content=\"%s\">\n", + add_word_args ("<meta name=\"description\" content=\"%s\">\n", document_description); - add_word_args ("<meta name=generator content=\"makeinfo %s\">\n", VERSION); - add_word ("<link href=\"http://www.gnu.org/software/texinfo/\" rel=generator-home>\n"); + add_word_args ("<meta name=\"generator\" content=\"makeinfo %s\">\n", + VERSION); + add_word ("<link href=\"http://www.gnu.org/software/texinfo/\" \ +rel=\"generator-home\">\n"); if (copying_text) { /* copying_text has already been fully expanded in @@ -71,9 +75,9 @@ html_output_head () add_word ("</head>\n<body>\n"); - if (title && !html_title_written) + if (title && !html_title_written && titlepage_cmd_present) { - add_word_args ("<h1>%s</h1>\n", html_title); + add_word_args ("<h1 class=\"settitle\">%s</h1>\n", html_title); html_title_written = 1; } } @@ -135,6 +139,34 @@ escape_string (string) free (string); return newstring - newlen; } + +/* Save current tag. */ +void +push_tag (tag) + char *tag; +{ + HSTACK *newstack = xmalloc (sizeof (HSTACK)); + + newstack->tag = tag; + newstack->next = htmlstack; + htmlstack = newstack; +} + +/* Get last tag. */ +void +pop_tag () +{ + HSTACK *tos = htmlstack; + + if (!tos) + { + line_error (_("[unexpected] no html tag to pop")); + return; + } + + htmlstack = htmlstack->next; + free (tos); +} /* Open or close TAG according to START_OR_END. */ void @@ -142,6 +174,9 @@ insert_html_tag (start_or_end, tag) int start_or_end; char *tag; { + char *old_tag = NULL; + int do_return = 0; + if (!paragraph_is_open && (start_or_end == START)) { /* Need to compensate for the <p> we are about to insert, or @@ -150,11 +185,47 @@ insert_html_tag (start_or_end, tag) adjust_braces_following (output_paragraph_offset, 3); add_word ("<p>"); } - add_char ('<'); + if (start_or_end != START) - add_char ('/'); - add_word (tag); - add_char ('>'); + pop_tag (tag); + + if (htmlstack) + old_tag = htmlstack->tag; + + if (htmlstack + && (strcmp (htmlstack->tag, tag) == 0)) + do_return = 1; + + if (start_or_end == START) + push_tag (tag); + + if (do_return) + return; + + /* texinfo.tex doesn't support more than one font attribute + at the same time. */ + if ((start_or_end == START) && old_tag && *old_tag) + { + add_word ("</"); + add_word (old_tag); + add_char ('>'); + } + + if (*tag) + { + add_char ('<'); + if (start_or_end != START) + add_char ('/'); + add_word (tag); + add_char ('>'); + } + + if ((start_or_end != START) && old_tag && *old_tag) + { + add_char ('<'); + add_word (old_tag); + add_char ('>'); + } } /* Output an HTML <link> to the filename for NODE, including the @@ -295,8 +366,8 @@ nodename_to_filename_1 (nodename, href) p = strchr (nodename, ')'); if (p == NULL) { - line_error (_("Invalid node name: `%s'"), nodename); - exit (1); + line_error (_("[unexpected] invalid node name: `%s'"), nodename); + xexit (1); } length = p - nodename - 1; |