MarkdownGridTableCell Class
A cell of a grid table: its text is a document of its own.
public sealed class MarkdownGridTableCellRemarks
The positions of the nodes of MarkdownGridTableCell.Content are in the text of the cell: MarkdownGridTableCell.MapPosition and MarkdownGridTableCell.MapSpan give the positions in the text of the tree of the table.
Properties
| Name | Description |
|---|---|
| ColumnIndex | Gets the index of the first column of the cell. |
| ColumnSpan | Gets the number of columns of the cell. |
| Content | Gets the content of the cell: its text, parsed with the options of the table, whose reference links can use the definitions of the tree of the table. |
| RowSpan | Gets the number of rows of the cell. |
| Text | Gets the text of the cell: the text of each of its lines between its |, without the whitespace at the end. |
ColumnIndex
MarkdownGridTableCell.csColumnSpan
MarkdownGridTableCell.csContent
MarkdownGridTableCell.csGets the content of the cell: its text, parsed with the options of the table, whose reference links can use the definitions of the tree of the table.
public MarkdownSyntaxTree Content { get; }Property value
RowSpan
MarkdownGridTableCell.csMethods
| Name | Description |
|---|---|
| MapPosition(int) | Gets the position in the text of the tree of the table of a position in MarkdownGridTableCell.Text, the text of MarkdownGridTableCell.Content. The line ending that separates two lines of the text is the end of the first one. |
| MapSpan(TextSpan) | Gets the span in the text of the tree of the table of a span of MarkdownGridTableCell.Text, the text of MarkdownGridTableCell.Content, such as the span of a node of MarkdownGridTableCell.Content. A span on several lines covers the borders of the cells between them, and the cells next to the cell on these lines. |
MapPosition(int)
MarkdownGridTableCell.csGets the position in the text of the tree of the table of a position in MarkdownGridTableCell.Text, the text of MarkdownGridTableCell.Content. The line ending that separates two lines of the text is the end of the first one.
Parameters
positionint- A position in
MarkdownGridTableCell.Text, from 0 to its length.
Returns
Exceptions
ArgumentOutOfRangeExceptionpositionis negative or greater than the length ofMarkdownGridTableCell.Text.
Example
var options = new MarkdownParseOptions { Extensions = MarkdownExtensions.GridTables };
var text = "Intro\n\n+---------------+\n| See [a](/u) |\n| and [b](/v) |\n+---------------+\n";
var tree = MarkdownSyntaxTree.ParseText(text, options);
var cell = tree.GetRoot().Blocks.OfType<MarkdownGridTableSyntax>().Single().Rows[0].Cells[0];
// The nodes of the content of the cell are not in the tree, and their spans are in the text of the cell
Assert.Empty(tree.GetRoot().DescendantNodes().OfType<MarkdownLinkSyntax>());
var link = cell.Content.GetRoot().DescendantNodes().OfType<MarkdownLinkSyntax>().Last();
Assert.Equal("[b](/v)", cell.Text.Substring(link.Span.Start, link.Span.Length));
// MapSpan gives the span of the link in the text of the tree
var span = cell.MapSpan(link.Span);
Assert.Equal("[b](/v)", text.Substring(span.Start, span.Length));MapSpan(TextSpan)
MarkdownGridTableCell.csGets the span in the text of the tree of the table of a span of MarkdownGridTableCell.Text, the text of MarkdownGridTableCell.Content, such as the span of a node of MarkdownGridTableCell.Content. A span on several lines covers the borders of the cells between them, and the cells next to the cell on these lines.
Parameters
spanTextSpan
Returns
Exceptions
ArgumentOutOfRangeException- The span ends after
MarkdownGridTableCell.Text.