ascii: Print syntax in output single-spaced.
[pspp-builds.git] / src / output / html.c
index 4452e40b678bd8feb6accf8fb26b75d750a839eb..45c9a1ef730762df544128f488f227568d082517 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2009, 2010, 2011 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
@@ -55,8 +55,6 @@ struct html_driver
     char *command_name;
     FILE *file;
     size_t chart_cnt;
-
-    bool in_syntax;
   };
 
 static const struct output_driver_class html_driver_class;
@@ -117,7 +115,7 @@ html_create (const char *file_name, enum settings_output_devices device_type,
          html->file);
   fputs ("<META HTTP-EQUIV=\"Content-Type\" "
          "CONTENT=\"text/html; charset=utf-8\">\n", html->file);
-  fputs ("<STYLE>\n"
+  fputs ("<STYLE TYPE=\"text/css\">\n"
          "<!--\n"
          "body {\n"
          "  background: white;\n"
@@ -200,11 +198,6 @@ html_destroy (struct output_driver *driver)
 
   if (html->file != NULL)
     {
-      if (html->in_syntax)
-        {
-          fprintf (html->file, "</PRE>\n");
-          html->in_syntax = false;
-        }
       fprintf (html->file,
                "</BODY>\n"
                "</HTML>\n"
@@ -217,13 +210,6 @@ html_destroy (struct output_driver *driver)
   free (html);
 }
 
-static bool
-is_syntax_item (const struct output_item *item)
-{
-  return (is_text_item (item)
-          && text_item_get_type (to_text_item (item)) == TEXT_ITEM_SYNTAX);
-}
-
 static void
 html_submit (struct output_driver *driver,
              const struct output_item *output_item)
@@ -232,12 +218,6 @@ html_submit (struct output_driver *driver,
 
   output_driver_track_current_command (output_item, &html->command_name);
 
-  if (html->in_syntax && !is_syntax_item (output_item))
-    {
-      fprintf (html->file, "</PRE>\n");
-      html->in_syntax = false;
-    }
-
   if (is_table_item (output_item))
     {
       struct table_item *table_item = to_table_item (output_item);
@@ -253,7 +233,9 @@ html_submit (struct output_driver *driver,
                                      html->chart_cnt++);
       if (file_name != NULL)
         {
-          fprintf (html->file, "<IMG SRC=\"%s\"/>", file_name);
+         const char *title = chart_item_get_title (chart_item);
+          fprintf (html->file, "<IMG SRC=\"%s\" ALT=\"Chart: %s\">",
+                  file_name, title ? title : _("No description"));
           free (file_name);
         }
     }
@@ -289,14 +271,9 @@ html_submit (struct output_driver *driver,
           break;
 
         case TEXT_ITEM_SYNTAX:
-          if (!html->in_syntax)
-            {
-              fprintf (html->file, "<PRE class=\"syntax\">");
-              html->in_syntax = true;
-            }
-          else
-            putc ('\n', html->file);
+          fprintf (html->file, "<PRE class=\"syntax\">");
           escape_string (html->file, s, strlen (s), " ");
+          fprintf (html->file, "</PRE>\n");
           break;
 
         case TEXT_ITEM_PARAGRAPH:
@@ -418,16 +395,16 @@ html_output_table (struct html_driver *html, struct table_item *item)
 
           alignment = cell.options & TAB_ALIGNMENT;
           if (alignment != TAB_LEFT)
-            fprintf (html->file, " ALIGN=%s",
+            fprintf (html->file, " ALIGN=\"%s\"",
                      alignment == TAB_RIGHT ? "RIGHT" : "CENTER");
 
           colspan = table_cell_colspan (&cell);
           if (colspan > 1)
-            fprintf (html->file, " COLSPAN=%d", colspan);
+            fprintf (html->file, " COLSPAN=\"%d\"", colspan);
 
           rowspan = table_cell_rowspan (&cell);
           if (rowspan > 1)
-            fprintf (html->file, " ROWSPAN=%d", rowspan);
+            fprintf (html->file, " ROWSPAN=\"%d\"", rowspan);
 
           /* Cell borders. */
           n_borders = 0;