/[global]/global/htags/common.c
ViewVC logotype

Diff of /global/htags/common.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by shigio, Mon Apr 11 00:34:46 2005 UTC revision 1.37 by shigio, Sat Apr 16 15:17:40 2005 UTC
# Line 109  const char *noframes_begin     = "<noframes> Line 109  const char *noframes_begin     = "<noframes>
109  const char *noframes_end        = "</noframes>";  const char *noframes_end        = "</noframes>";
110    
111  /*  /*
112     * 1: Enforce XHTML1.0 strict or XHTML1.1.
113     */
114    static int strict_xhtml = 0;
115    
116    /*
117   * print string and new line.   * print string and new line.
118   *   *
119   * This function is a replacement of fprintf(op, "%s\n", s) in htags.   * This function is a replacement of fprintf(op, "%s\n", s) in htags.
# Line 125  fputs_nl(s, op) Line 130  fputs_nl(s, op)
130  /*  /*
131   * XHTML support.   * XHTML support.
132   *   *
133   * If the --xhtml option is specified then we take 'XHTML 1.1'.   * If the --xhtml option is specified, htags(1) generates XHTML output.
  * If both of the --xhtml and the --frame option are specified  
  * then we take 'XHTML 1.0 Frameset'.  
134   * We define each style for the tags in 'style.css' in this directory.   * We define each style for the tags in 'style.css' in this directory.
135   */   */
136  void  void
137  setup_xhtml(void)  setup_xhtml(void)
138  {  {
139            if (!strcmp(xhtml_version, "1.1") && !Fflag)
140                    strict_xhtml = 1;
141          html_begin              = "<html xmlns='http://www.w3.org/1999/xhtml'>";          html_begin              = "<html xmlns='http://www.w3.org/1999/xhtml'>";
142          html_end                = "</html>";          html_end                = "</html>";
143          html_head_begin         = "<head>";          html_head_begin         = "<head>";
# Line 220  gen_page_begin(title, subdir) Line 225  gen_page_begin(title, subdir)
225    
226          strbuf_clear(sb);          strbuf_clear(sb);
227          if (enable_xhtml) {          if (enable_xhtml) {
228                  strbuf_puts_nl(sb, "<?xml version='1.0' encoding='ISO-8859-1'?>");                  /*
229                  strbuf_sprintf(sb, "<?xml-stylesheet type='text/css' href='%sstyle.css'?>\n", dir);                   * Since some browser cannot treat "<?xml...>", we don't
230                     * write the declaration as long as XHTML1.1 is not required.
231                     */
232                    if (strict_xhtml) {
233                            strbuf_puts_nl(sb, "<?xml version='1.0' encoding='ISO-8859-1'?>");
234                            strbuf_sprintf(sb, "<?xml-stylesheet type='text/css' href='%sstyle.css'?>\n", dir);
235                    }
236                    /*
237                     * If the --frame option are specified then we take
238                     * 'XHTML 1.0 Frameset', else if the config variable
239                     * 'xhtml_version' is set to '1.1' then we take 'XHTML 1.1',
240                     * else 'XHTML 1.0 Transitional'.
241                     */
242                  if (Fflag)                  if (Fflag)
243                          strbuf_puts_nl(sb, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Frameset//EN' 'http:://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd'>");                          strbuf_puts_nl(sb, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Frameset//EN' 'http:://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd'>");
244                  else                  else if (strict_xhtml)
245                          strbuf_puts_nl(sb, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http:://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>");                          strbuf_puts_nl(sb, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http:://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>");
246                    else
247                            strbuf_puts_nl(sb, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http:://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd'>");
248          }          }
249          strbuf_puts_nl(sb, html_begin);          strbuf_puts_nl(sb, html_begin);
250          strbuf_puts_nl(sb, html_head_begin);          strbuf_puts_nl(sb, html_head_begin);
# Line 286  const char * Line 305  const char *
305  gen_name_number(number)  gen_name_number(number)
306          int number;          int number;
307  {  {
308          STATIC_STRBUF(sb);          static char buf[32];
         const char *id = enable_xhtml ? "id" : "name";  
309    
310          strbuf_clear(sb);          snprintf(buf, sizeof(buf), "%d", number);
311          strbuf_sprintf(sb, "<a %s='%d'%s>", id, number, empty_element);          return gen_name_string(buf);
         return strbuf_value(sb);  
312  }  }
313  /*  /*
314   * Generate name tag.   * Generate name tag.
# Line 301  gen_name_string(name) Line 318  gen_name_string(name)
318          const char *name;          const char *name;
319  {  {
320          STATIC_STRBUF(sb);          STATIC_STRBUF(sb);
         const char *id = enable_xhtml ? "id" : "name";  
321    
322          strbuf_clear(sb);          strbuf_clear(sb);
323          strbuf_sprintf(sb, "<a %s='%s'%s>", id, name, empty_element);          if (enable_xhtml) {
324                    /*
325                     * Since some browser cannot understand "<a id='xxx' />",
326                     * we put both of 'id=' and 'name=' as long as XHTML1.1
327                     * is not required. XHTML1.1 prohibit 'name='.
328                     */
329                    if (strict_xhtml)
330                            strbuf_sprintf(sb, "<a id='%s' />", name);
331                    else
332                            strbuf_sprintf(sb, "<a id='%s' name='%s' />", name, name);
333            } else {
334                    strbuf_sprintf(sb, "<a name='%s'>", name);
335            }
336          return strbuf_value(sb);          return strbuf_value(sb);
337  }  }
338  /*  /*

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26