pub struct TableBlock<'src> { /* private fields */ }Expand description
A table is a delimited block that arranges content into a grid of rows and columns.
A table is introduced by a table delimiter (|===, or !=== for a nested
table) and closed by a matching delimiter. By default cells are separated
using prefix-separated value (PSV) syntax: the table’s cell separator — a
vertical bar (|) by default — at the start of a line or preceded by
whitespace begins a new cell. Cells flow, in document order, into rows whose
length is fixed by the number of columns. (The separator defaults to !
inside a nested table and can be overridden with the separator attribute;
see below.)
The number of columns is determined either by the cols attribute or,
implicitly, by the number of cells found in the first non-empty line after
the opening delimiter.
§Data formats
In addition to the default PSV format, a table can be populated from
delimiter-separated data with the format attribute:
csv (comma-separated values), tsv (tab-separated values), or dsv
(delimited values, colon-separated by default). The ,=== and :===
shorthand delimiters select the CSV and DSV formats respectively without an
explicit format attribute. In a data format the separator is placed
between values (not in front of each cell) and a cell carries no
formatting spec; cell formatting is instead applied per column with the
cols attribute. See DataFormat for the parsing rules.
Column specifier style operators (the a, d, e, h, l, m, and s
operators) are supported, along with proportional width and the horizontal
and vertical alignment operators. Per-cell horizontal and vertical alignment
operators are supported and override the column’s alignment, and a per-cell
style operator (in the last position of the cell specifier) is supported and
overrides the column’s style. The per-cell span (+) operator is supported:
a cell can span multiple columns (<n>+), multiple rows (.<n>+), or a
block of both (<n>.<n>+). The per-cell duplication (*) operator is
supported: a cell with a duplication factor (<n>*) clones its content and
properties into <n> consecutive cells.
Table sizing is supported: the width attribute sets a fixed
table width, the autowidth option (is_autowidth)
sizes the table and its columns to their content, and an individual column
can be made autowidth with the ~ width value.
Table borders are supported: the frame attribute controls
the border around the table and the grid attribute controls
the borders between cells. Each falls back to a document-level default
(table-frame / table-grid) and then to all.
Zebra striping is supported via the stripes attribute,
which falls back to the table-stripes document attribute and then to
none.
Nested tables are supported: an AsciiDoc cell may
contain its own table. The cell separator defaults to the vertical bar (|)
but switches to the exclamation mark (!) inside an AsciiDoc cell, so a
nested table is opened with !=== and separates its cells with !. The
separator attribute overrides the default separator with an explicit
character at any level.
Implementations§
Source§impl<'src> TableBlock<'src>
impl<'src> TableBlock<'src>
Sourcepub fn caption(&self) -> Option<&str>
pub fn caption(&self) -> Option<&str>
Returns the caption assigned to this table, if any.
A titled table is captioned with a label that a processor prepends to
the title. By default the label combines the
table-caption attribute and an automatically incremented number (e.g.
"Table 1. "). An explicit caption attribute on the table overrides
this with a verbatim label and no number; an explicitly empty caption
(e.g. [caption=]) removes the label entirely. The caption is absent
when the table has no title, when table-caption has been unset and no
explicit caption is given, or when an empty caption was supplied.
Sourcepub fn number(&self) -> Option<usize>
pub fn number(&self) -> Option<usize>
Returns the number assigned to this table, if any.
A titled table for which the table-caption attribute is set is
numbered with an automatically incremented, document-wide table counter
(the same number that appears in its caption, e.g.
the 1 in "Table 1. "). The number is absent when the table is
not captioned, or when its caption comes from an explicit
(unnumbered) caption attribute.
Sourcepub fn columns(&self) -> &[TableColumn]
pub fn columns(&self) -> &[TableColumn]
Returns the columns of this table.
Sourcepub fn data_format(&self) -> DataFormat
pub fn data_format(&self) -> DataFormat
Returns the DataFormat used to populate this table.
The format comes from the format attribute on the table (psv, csv,
tsv, or dsv) or from a shorthand delimiter (,=== selects CSV,
:=== selects DSV). When neither is present the format defaults to
DataFormat::Psv.
Sourcepub fn width(&self) -> Option<usize>
pub fn width(&self) -> Option<usize>
Returns the fixed width of this table, as a percentage of the content
area, when the width attribute is set.
The width attribute is an integer percentage from 1 to 100; the
trailing % sign is optional ([width=75%] and [width=75] are
equivalent). A value outside that range, or one that is not an integer,
is ignored and reported as None. When the attribute is absent the
table spans the width of the content area and this returns None.
Sourcepub fn is_autowidth(&self) -> bool
pub fn is_autowidth(&self) -> bool
Sourcepub fn frame(&self) -> Frame
pub fn frame(&self) -> Frame
Returns the Frame that controls the border drawn around this table.
The frame comes from the frame attribute on the table, which accepts
all, ends, sides, or none. When the attribute is absent the
value is taken from the table-frame document attribute, and when
that too is absent it defaults to Frame::All.
Sourcepub fn grid(&self) -> Grid
pub fn grid(&self) -> Grid
Returns the Grid that controls the borders drawn between this
table’s cells.
The grid comes from the grid attribute on the table, which accepts
all, rows, cols, or none. When the attribute is absent the value
is taken from the table-grid document attribute, and when that too is
absent it defaults to Grid::All.
Sourcepub fn stripes(&self) -> Stripes
pub fn stripes(&self) -> Stripes
Returns the Stripes that control which rows of this table are shaded
to create a zebra-striping effect.
The stripes come from the stripes attribute on the table, which
accepts none, even, odd, all, or hover. When the attribute
is absent the value is taken from the table-stripes document
attribute, and when that too is absent it defaults to
Stripes::None.
As a shorthand, a stripes-<value> role on the table (e.g.
[.stripes-even]) applies the same CSS class directly without setting
the stripes attribute. That shorthand does not affect this value
(which remains Stripes::None); the role is instead reported
among the table’s roles.
Sourcepub fn header_row(&self) -> Option<&TableRow<'src>>
pub fn header_row(&self) -> Option<&TableRow<'src>>
Returns the header row of this table, if one was declared.
Returns the footer row of this table, if one was declared.
Trait Implementations§
Source§impl<'src> Clone for TableBlock<'src>
impl<'src> Clone for TableBlock<'src>
Source§fn clone(&self) -> TableBlock<'src>
fn clone(&self) -> TableBlock<'src>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'src> Debug for TableBlock<'src>
impl<'src> Debug for TableBlock<'src>
impl<'src> Eq for TableBlock<'src>
Source§impl<'src> HasSpan<'src> for TableBlock<'src>
impl<'src> HasSpan<'src> for TableBlock<'src>
Source§impl<'src> IsBlock<'src> for TableBlock<'src>
impl<'src> IsBlock<'src> for TableBlock<'src>
Source§fn content_model(&self) -> ContentModel
fn content_model(&self) -> ContentModel
ContentModel for this block.Source§fn raw_context(&self) -> CowStr<'src>
fn raw_context(&self) -> CowStr<'src>
Source§fn title_source(&'src self) -> Option<Span<'src>>
fn title_source(&'src self) -> Option<Span<'src>>
Source§fn caption(&self) -> Option<&str>
fn caption(&self) -> Option<&str>
Source§fn number(&self) -> Option<usize>
fn number(&self) -> Option<usize>
Source§fn anchor_reftext(&'src self) -> Option<Span<'src>>
fn anchor_reftext(&'src self) -> Option<Span<'src>>
Source§fn attrlist(&'src self) -> Option<&'src Attrlist<'src>>
fn attrlist(&'src self) -> Option<&'src Attrlist<'src>>
Source§fn rendered_content(&'src self) -> Option<&'src str>
fn rendered_content(&'src self) -> Option<&'src str>
Source§fn resolved_context(&'src self) -> CowStr<'src>
fn resolved_context(&'src self) -> CowStr<'src>
Source§fn declared_style(&'src self) -> Option<&'src str>
fn declared_style(&'src self) -> Option<&'src str>
Source§fn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
fn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
Source§fn nested_blocks_mut(&mut self) -> &mut [Block<'src>]
fn nested_blocks_mut(&mut self) -> &mut [Block<'src>]
Source§fn content_mut(&mut self) -> Option<&mut Content<'src>>
fn content_mut(&mut self) -> Option<&mut Content<'src>>
Source§fn options(&'src self) -> Vec<&'src str>
fn options(&'src self) -> Vec<&'src str>
Source§fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
true if this block has the named option. Read moreSource§fn substitution_group(&'src self) -> SubstitutionGroup
fn substitution_group(&'src self) -> SubstitutionGroup
Source§impl<'src> PartialEq for TableBlock<'src>
impl<'src> PartialEq for TableBlock<'src>
Source§fn eq(&self, other: &TableBlock<'src>) -> bool
fn eq(&self, other: &TableBlock<'src>) -> bool
self and other values to be equal, and is used by ==.