diff options
Diffstat (limited to 'contrib/texinfo/makeinfo/cmds.c')
-rw-r--r-- | contrib/texinfo/makeinfo/cmds.c | 174 |
1 files changed, 113 insertions, 61 deletions
diff --git a/contrib/texinfo/makeinfo/cmds.c b/contrib/texinfo/makeinfo/cmds.c index 7de972b892c9..5ff0b5d0a1ca 100644 --- a/contrib/texinfo/makeinfo/cmds.c +++ b/contrib/texinfo/makeinfo/cmds.c @@ -1,7 +1,8 @@ /* cmds.c -- Texinfo commands. - $Id: cmds.c,v 1.79 2002/03/28 16:35:29 karl Exp $ + $Id: cmds.c,v 1.16 2003/01/12 15:18:24 karl Exp $ - Copyright (C) 1998, 99, 2000, 01, 02 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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 @@ -22,6 +23,7 @@ #include "defun.h" #include "files.h" #include "footnote.h" +#include "html.h" #include "insertion.h" #include "lang.h" #include "macro.h" @@ -64,7 +66,7 @@ void cm_defcodeindex (), cm_result (), cm_expansion (), cm_equiv (), cm_print (), cm_error (), cm_point (), cm_today (), cm_flushleft (), cm_flushright (), cm_finalout (), cm_cartouche (), cm_detailmenu (), - cm_multitable (), cm_settitle (), cm_titlefont (), cm_tt (), + cm_multitable (), cm_settitle (), cm_titlefont (), cm_titlepage (), cm_tie (), cm_tt (), cm_verbatim (), cm_verbatiminclude (); /* Conditionals. */ @@ -237,9 +239,11 @@ COMMAND command_table[] = { { "ifnotinfo", cm_ifnotinfo, NO_BRACE_ARGS }, { "ifnotplaintext", cm_ifnotplaintext, NO_BRACE_ARGS }, { "ifnottex", cm_ifnottex, NO_BRACE_ARGS }, + { "ifnotxml", cm_ifnotxml, NO_BRACE_ARGS }, { "ifplaintext", cm_ifplaintext, NO_BRACE_ARGS }, { "ifset", cm_ifset, NO_BRACE_ARGS }, { "iftex", cm_iftex, NO_BRACE_ARGS }, + { "ifxml", cm_ifxml, NO_BRACE_ARGS }, { "ignore", command_name_condition, NO_BRACE_ARGS }, { "image", cm_image, BRACE_ARGS }, { "include", cm_include, NO_BRACE_ARGS }, @@ -320,10 +324,11 @@ COMMAND command_table[] = { { "tab", cm_tab, NO_BRACE_ARGS }, { "table", cm_table, NO_BRACE_ARGS }, { "tex", cm_tex, NO_BRACE_ARGS }, + { "tie", cm_tie, BRACE_ARGS }, { "tieaccent", cm_accent, MAYBE_BRACE_ARGS }, { "tindex", cm_tindex, NO_BRACE_ARGS }, { "titlefont", cm_titlefont, BRACE_ARGS }, - { "titlepage", command_name_condition, NO_BRACE_ARGS }, + { "titlepage", cm_titlepage, NO_BRACE_ARGS }, { "today", cm_today, BRACE_ARGS }, { "top", cm_top, NO_BRACE_ARGS }, { "u", cm_accent, MAYBE_BRACE_ARGS }, @@ -345,6 +350,7 @@ COMMAND command_table[] = { { "vindex", cm_vindex, NO_BRACE_ARGS }, { "vtable", cm_vtable, NO_BRACE_ARGS }, { "w", cm_w, BRACE_ARGS }, + { "xml", cm_html, NO_BRACE_ARGS }, { "xref", cm_xref, BRACE_ARGS }, /* Deprecated commands. These used to be for italics. */ @@ -387,9 +393,9 @@ insert_space (arg) if (arg == START) { if (xml && !docbook) - xml_insert_entity ("space"); + xml_insert_entity ("space"); else - add_char (' '); + add_char (' '); } } @@ -418,11 +424,12 @@ cm_dots (arg) if (arg == START) { if (xml && !docbook) - xml_insert_entity ("dots"); + xml_insert_entity ("dots"); else if (docbook) - xml_insert_entity ("hellip"); + xml_insert_entity ("hellip"); else - add_word (html ? "<small>...</small>" : "..."); + add_word (html && !in_fixed_width_font + ? "<small class=\"dots\">...</small>" : "..."); } } @@ -441,7 +448,8 @@ cm_enddots (arg) add_char ('.'); } else - add_word (html ? "<small>...</small>." : "...."); + add_word (html && !in_fixed_width_font + ? "<small class=\"enddots\">....</small>" : "...."); } } @@ -553,24 +561,24 @@ cm_code (arg) xml_insert_element (CODE, arg); else { - extern int printing_index; + extern int printing_index; - if (arg == START) - { - in_fixed_width_font++; + if (arg == START) + { + in_fixed_width_font++; - if (html) + if (html) + insert_html_tag (arg, "code"); + else if (!printing_index) + add_char ('`'); + } + else if (html) insert_html_tag (arg, "code"); - else if (!printing_index) - add_char ('`'); - } - else if (html) - insert_html_tag (arg, "code"); - else - { - if (!printing_index) - add_meta_char ('\''); - } + else + { + if (!printing_index) + add_meta_char ('\''); + } } } @@ -604,9 +612,10 @@ cm_url (arg, start, end) else if (html) { if (arg == START) - add_word ("<<code>"); - else - add_word ("</code>>"); + add_word ("<"); + insert_html_tag (arg, "code"); + if (arg != START) + add_word (">"); } else if (arg == START) @@ -748,7 +757,7 @@ cm_verb (arg) last_char_was_newline = 0; if (html) - add_word ("<pre>"); + add_word ("<tt>"); if (input_text_offset < input_text_length) { @@ -770,18 +779,28 @@ cm_verb (arg) character = curchar (); if (character == '\n') - line_number++; - /* - Assume no newlines in END_VERBATIM - */ + { + line_number++; + if (html) + add_word ("<br>\n"); + } + + else if (html && character == '<') + add_word ("<"); + + else if (html && character == '&') + add_word ("&"); + else if (character == delimiter) - { + { /* Assume no newlines in END_VERBATIM. */ seen_end = 1; input_text_offset++; break; } - add_char (character); + else + add_char (character); + input_text_offset++; } @@ -798,9 +817,12 @@ cm_verb (arg) } if (html) - add_word ("</pre>"); + add_word ("</tt>"); + + in_fixed_width_font--; } + void cm_strong (arg, position) int arg, position; @@ -872,25 +894,9 @@ cm_r (arg) xml_insert_element (R, arg); else { - extern int printing_index; + if (html) + insert_html_tag (arg, ""); - /* People use @r{} in index entries like this: - - @findex foo@r{, some text} - - This is supposed to produce output as if the entry were saying - "@code{foo}, some text", since the "fn" index is typeset as - @code. The following attempts to do the same in HTML. Note that - this relies on the fact that only @code bumps up the variable - in_fixed_width_font while processing index entries in HTML mode. */ - if (html && printing_index) - { - int level = in_fixed_width_font; - - while (level--) - insert_html_tag (arg == START ? END : START, "code"); - } - not_fixed_width (arg); } } @@ -902,7 +908,27 @@ cm_titlefont (arg) if (xml) xml_insert_element (TITLEFONT, arg); else - not_fixed_width (arg); + { + not_fixed_width (arg); + if (html) + { + html_title_written = 1; /* suppress title from @settitle */ + if (arg == START) + add_word ("<h1 class=\"titlefont\">"); + else + add_word ("</h1>\n"); + } + } +} + +int titlepage_cmd_present = 0; + +void +cm_titlepage (arg) + int arg; +{ + titlepage_cmd_present = 1; + command_name_condition (); } /* Various commands are no-op's. */ @@ -932,6 +958,22 @@ cm_w (arg, start, end) } +/* An unbreakable word space. Same as @w{ } for makeinfo, but different + for TeX (the space stretches and stretches, and does not inhibit + hyphenation). */ +void +cm_tie (arg) + int arg; +{ + if (arg == START) + { + cm_w (START); + add_char (' '); + } + else + cm_w (END); +} + /* Explain that this command is obsolete, thus the user shouldn't do anything with it. */ static void @@ -976,9 +1018,16 @@ cm_settitle () { xml_begin_document (current_output_filename); xml_insert_element (SETTITLE, START); + xml_in_book_title = 1; get_rest_of_line (0, &title); execute_string ("%s", title); + xml_in_book_title = 0; xml_insert_element (SETTITLE, END); + if (docbook && !xml_in_bookinfo) + { + xml_insert_element (BOOKINFO, START); + xml_in_bookinfo = 1; + } } else get_rest_of_line (0, &title); @@ -1115,7 +1164,7 @@ cm_center () execute_string ("%s", (char *)line); free (line); uninhibit_output_flushing (); - if (html) + if (html) add_word ("</div>"); else @@ -1214,7 +1263,7 @@ cm_exdent () int save_indent = current_indent; int save_in_fixed_width_font = in_fixed_width_font; - /* Read argument */ + /* Read argument. */ get_rest_of_line (0, &line); /* Exdent the output. Actually this may be a no-op. */ @@ -1242,6 +1291,7 @@ cm_exdent () current_indent = save_indent; in_fixed_width_font = save_in_fixed_width_font; + start_paragraph (); } /* @@ -1253,13 +1303,17 @@ static void handle_include (verbatim_include) int verbatim_include; { - char *filename; + char *arg, *filename; if (macro_expansion_output_stream && !executing_string) me_append_before_this_command (); close_paragraph (); - get_rest_of_line (0, &filename); + get_rest_of_line (0, &arg); + /* We really only want to expand @value, but it's easier to just do + everything. TeX will only work with @value. */ + filename = text_expansion (arg); + free (arg); if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); @@ -1283,8 +1337,6 @@ handle_include (verbatim_include) if (!find_and_load (filename)) { - extern int errno; - popfile (); line_number--; |