public EncodedData? Encode()

in src/ResultEncoding/Table.cs [111:147]


        public EncodedData? Encode(object displayable)
        {
            if (displayable is ITable table)
            {
                var headers = table.Headers;
                var cells = table.Cells;

                return new EncodedData
                {
                    Data =
                        "<table>" +
                            "<thead>" +
                                "<tr>" +
                                    String.Join("",
                                        headers.Select(
                                            header => $"<th {TableCellAlignment.ToStyleAttribute()}>{header}</th>"
                                        )
                                    ) +
                                "</tr>" +
                            "</thead>" +
                            "<tbody>" +
                                String.Join("",
                                    cells.Select(row =>
                                        "<tr>" +
                                        String.Join("",
                                            row.Select(
                                                cell => $"<td {TableCellAlignment.ToStyleAttribute()}>{cell}</td>"
                                            )
                                        ) +
                                        "</tr>"
                                    )
                                ) +
                            "</tbody>" +
                        "</table>"
                };
            } else return null;
        }