@code{show} is a 32-bit signed integer. It is positive to show the
footnote or negative to hide it. Its magnitude is often 1, and in
other cases tends to be the number of references to the footnote.
+It is safe to write 1 to show a footnote and -1 to hide it.
@node SPV Light Member Areas
@subsection Areas
}
size_t footnote_ofs = ds_length (&body);
+ size_t n_footnotes = 0;
for (size_t i = 0; i < value->n_footnotes; i++)
{
- if (i)
- ds_put_byte (&body, ',');
-
- size_t idx = value->footnote_indexes[i];
- pivot_footnote_format_marker (pt->footnotes[idx], pt, &body);
+ const struct pivot_footnote *f
+ = pt->footnotes[value->footnote_indexes[i]];
+ if (f->show)
+ {
+ if (n_footnotes++)
+ ds_put_byte (&body, ',');
+ pivot_footnote_format_marker (f, pt, &body);
+ }
}
/* Allow footnote markers to occupy the right margin. That way, numbers
if (cell->value->n_footnotes > 0)
{
fputs ("<sup>", html->file);
+ size_t n_footnotes = 0;
for (size_t i = 0; i < cell->value->n_footnotes; i++)
{
- if (i > 0)
- putc (',', html->file);
-
- size_t idx = cell->value->footnote_indexes[i];
- const struct pivot_footnote *f = pt->footnotes[idx];
+ const struct pivot_footnote *f
+ = pt->footnotes[cell->value->footnote_indexes[i]];
+ if (f->show)
+ {
+ if (n_footnotes++ > 0)
+ putc (',', html->file);
- char *marker = pivot_footnote_marker_string (f, pt);
- escape_string (html->file, marker, " ", "<br>");
- free (marker);
+ char *marker = pivot_footnote_marker_string (f, pt);
+ escape_string (html->file, marker, " ", "<br>");
+ free (marker);
+ }
}
fputs ("</sup>", html->file);
}
{
for (size_t i = 0; i < n_footnotes; i++)
{
- xmlTextWriterStartElement (odt->content_wtr, _xml("text:span"));
- xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"),
- _xml("superscript"));
const struct pivot_footnote *f = pt->footnotes[footnote_indexes[i]];
- char *s = pivot_footnote_marker_string (f, pt);
- write_xml_with_line_breaks (odt, s);
- free (s);
- xmlTextWriterEndElement (odt->content_wtr);
+ if (f->show)
+ {
+ xmlTextWriterStartElement (odt->content_wtr, _xml("text:span"));
+ xmlTextWriterWriteAttribute (odt->content_wtr,
+ _xml("text:style-name"),
+ _xml("superscript"));
+ char *s = pivot_footnote_marker_string (f, pt);
+ write_xml_with_line_breaks (odt, s);
+ free (s);
+ xmlTextWriterEndElement (odt->content_wtr);
+ }
}
}
size_t idx = cell.value->footnote_indexes[i];
assert (idx < pt->n_footnotes);
- if (!refs[idx])
+ if (!refs[idx] && pt->footnotes[idx]->show)
{
refs[idx] = true;
(*n_refs)++;
put_u32 (buf, table->n_footnotes);
for (size_t i = 0; i < table->n_footnotes; i++)
{
- put_value (buf, table->footnotes[i]->content);
- put_optional_value (buf, table->footnotes[i]->marker);
- put_u32 (buf, 0);
+ const struct pivot_footnote *f = table->footnotes[i];
+ put_value (buf, f->content);
+ put_optional_value (buf, f->marker);
+ put_u32 (buf, f->show ? 1 : -1);
}
/* Areas. */
const size_t *footnote_indexes,
size_t n_footnotes)
{
- if (n_footnotes > 0)
- shipout (&tex->token_list, "$^{");
+ size_t n_visible = 0;
for (size_t i = 0; i < n_footnotes; i++)
{
const struct pivot_footnote *f = pt->footnotes[footnote_indexes[i]];
- char *marker = pivot_footnote_marker_string (f, pt);
- tex_escape_string (tex, marker, true);
- free (marker);
+ if (f->show)
+ {
+ if (!n_visible++)
+ shipout (&tex->token_list, "$^{");
+
+ char *marker = pivot_footnote_marker_string (f, pt);
+ tex_escape_string (tex, marker, true);
+ free (marker);
+ }
}
- if (n_footnotes > 0)
+ if (n_visible)
shipout (&tex->token_list, "}$");
}
else
marker = NULL;
- pivot_table_create_footnote__ (pt, idx, marker, content);
+ bool show = !lex_match_id (lexer, "HIDE");
+ pivot_table_create_footnote__ (pt, idx, marker, content)->show = show;
}
static void
/display
/title "Pivot Table with Numeric Superscript Footnotes"[footnote 0]
/look marker=numeric level=super
+/display
+/title "Hidden Footnote"[footnote 0]
+/footnote[0] "First footnote" marker="*" hide
]])
AT_CHECK([pivot-table-test --table-look $srcdir/output/look.stt pivot.txt --box unicode], [0],
[[Pivot Table with Alphabetic Subscript Footnotes[*]
Caption[*]
*. First footnote
2. Second footnote
+
+Hidden Footnote[*]
+╭────────────┬──────────────────╮
+│ │ A[*] │
+│ ├───────┬──────────┤
+│Corner[*][2]│ B[2] │ C[*][2] │
+├────────────┼───────┼──────────┤
+│D[2] E[*] │ .00│ 1.00[*]│
+│ F[*][2]│2.00[2]│3.00[*][2]│
+╰────────────┴───────┴──────────╯
+Caption[*]
+2. Second footnote
]])
AT_CLEANUP