X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Foutput%2Fhtml.c;h=0546e5d3a2eb94612605d9af1e78e9cfb8098215;hb=8539b9672ca634e0bedf7a531709e845a6b451d6;hp=dcff0af085bcfe4e5feed0e843923c16b68c922a;hpb=29917c4f5908454803e663d2ad78bca4bc35e805;p=pspp
diff --git a/src/output/html.c b/src/output/html.c
index dcff0af085..0546e5d3a2 100644
--- a/src/output/html.c
+++ b/src/output/html.c
@@ -180,9 +180,7 @@ html_create (struct file_handle *fh, enum settings_output_devices device_type,
struct string_map *o)
{
struct output_driver *d;
- struct html_driver *html;
-
- html = xzalloc (sizeof *html);
+ struct html_driver *html = XZALLOC (struct html_driver);
d = &html->driver;
output_driver_init (&html->driver, &html_driver_class, fh_get_file_name (fh),
device_type);
@@ -247,7 +245,8 @@ html_destroy (struct output_driver *driver)
}
static void
-html_submit (struct output_driver *driver, const struct output_item *item)
+html_submit__ (struct output_driver *driver, const struct output_item *item,
+ int level)
{
struct html_driver *html = html_driver_cast (driver);
@@ -270,10 +269,9 @@ html_submit (struct output_driver *driver, const struct output_item *item)
}
break;
- case OUTPUT_ITEM_GROUP_OPEN:
- break;
-
- case OUTPUT_ITEM_GROUP_CLOSE:
+ case OUTPUT_ITEM_GROUP:
+ for (size_t i = 0; i < item->group.n_children; i++)
+ html_submit__ (driver, item->group.children[i], level + 1);
break;
case OUTPUT_ITEM_IMAGE:
@@ -302,9 +300,6 @@ html_submit (struct output_driver *driver, const struct output_item *item)
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- break;
-
case OUTPUT_ITEM_TABLE:
html_output_table (html, item);
break;
@@ -320,8 +315,7 @@ html_submit (struct output_driver *driver, const struct output_item *item)
case TEXT_ITEM_TITLE:
{
- int level = MIN (5, output_get_group_level ()) + 1;
- char tag[3] = { 'H', level + '1', '\0' };
+ char tag[3] = { 'H', MIN (5, level) + '0', '\0' };
print_title_tag (html->file, tag, s);
}
break;
@@ -345,6 +339,12 @@ html_submit (struct output_driver *driver, const struct output_item *item)
}
}
+static void
+html_submit (struct output_driver *driver, const struct output_item *item)
+{
+ html_submit__ (driver, item, 1);
+}
+
/* Write TEXT to file F, escaping characters as necessary for HTML. Spaces are
replaced by SPACE, which should be " " or " " New-lines are replaced by
NEWLINE, which might be "
" or "\n" or something else appropriate. */
@@ -585,26 +585,26 @@ html_put_table_cell (struct html_driver *html, const struct pivot_table *pt,
escape_string (html->file, s, " ", "
");
ds_destroy (&body);
- if (cell->value->n_subscripts)
+ const struct pivot_value_ex *ex = pivot_value_ex (cell->value);
+ if (ex->n_subscripts)
{
fputs ("", html->file);
- for (size_t i = 0; i < cell->value->n_subscripts; i++)
+ for (size_t i = 0; i < ex->n_subscripts; i++)
{
if (i)
putc (',', html->file);
- escape_string (html->file, cell->value->subscripts[i],
- " ", "
");
+ escape_string (html->file, ex->subscripts[i], " ", "
");
}
fputs ("", html->file);
}
- if (cell->value->n_footnotes > 0)
+ if (ex->n_footnotes > 0)
{
fputs ("", html->file);
size_t n_footnotes = 0;
- for (size_t i = 0; i < cell->value->n_footnotes; i++)
+ for (size_t i = 0; i < ex->n_footnotes; i++)
{
const struct pivot_footnote *f
- = pt->footnotes[cell->value->footnote_indexes[i]];
+ = pt->footnotes[ex->footnote_indexes[i]];
if (f->show)
{
if (n_footnotes++ > 0)
@@ -740,8 +740,8 @@ struct output_driver_factory html_driver_factory =
static const struct output_driver_class html_driver_class =
{
- "html",
- html_destroy,
- html_submit,
- NULL,
+ .name = "html",
+ .destroy = html_destroy,
+ .submit = html_submit,
+ .handles_groups = true,
};