char *separator; /* Field separator (usually comma or tab). */
int quote; /* Quote character (usually ' or ") or 0. */
char *quote_set; /* Characters that force quoting. */
+ bool titles; /* Print table titles? */
bool captions; /* Print table captions? */
char *file_name; /* Output file name. */
csv->quote = quote[0];
free (quote);
csv->quote_set = xasprintf ("\n\r\t%s%c", csv->separator, csv->quote);
+ csv->titles = parse_boolean (opt (d, o, "titles", "true"));
csv->captions = parse_boolean (opt (d, o, "captions", "true"));
csv->file_name = xstrdup (file_name);
csv->file = fn_open (csv->file_name, "w");
const struct table_item *item)
{
const struct table *t = table_item_get_table (item);
+ const char *title = table_item_get_title (item);
const char *caption = table_item_get_caption (item);
int y, x;
- if (csv->captions && caption != NULL)
+ if (csv->titles && title != NULL)
{
- csv_output_field_format (csv, "Table: %s", caption);
+ csv_output_field_format (csv, "Table: %s", title);
putc ('\n', csv->file);
}
table_cell_free (&cell);
}
}
+
+ if (csv->captions && caption != NULL)
+ {
+ csv_output_field_format (csv, "Caption: %s", caption);
+ putc ('\n', csv->file);
+ }
}
static void
if (is_table_item (output_item))
{
struct table_item *table_item = to_table_item (output_item);
+ const char *title = table_item_get_title (table_item);
const char *caption = table_item_get_caption (table_item);
const struct table *t = table_item_get_table (table_item);
int footnote_idx;
csv_put_separator (csv);
- if (csv->captions && caption != NULL)
+ if (csv->titles && title != NULL)
{
- csv_output_field_format (csv, "Table: %s", caption);
+ csv_output_field_format (csv, "Table: %s", title);
putc ('\n', csv->file);
}
putc ('\n', csv->file);
}
+ if (csv->captions && caption != NULL)
+ {
+ csv_output_field_format (csv, "Caption: %s", caption);
+ putc ('\n', csv->file);
+ }
+
if (footnote_idx)
{
size_t i;