dotmarkdown icon indicating copy to clipboard operation
dotmarkdown copied to clipboard

How to create a Table?

Open vonj opened this issue 1 year ago • 3 comments

I don't understand how to use for instance DotMarkdown.MarkdownBaseWriter.WriteStartTableCell()

I get exceptions, like:

Cannot write 'TableCell' when state is 'Table'

How do I get out of that state? In what order should the methods be called?

vonj avatar Sep 19 '23 22:09 vonj

Hi,

You have to start with WriteStartTable:

  • WriteStartTable
    • WriteStartTableRow
      • WriteStartTableCell

This is not convenient way how to create markdown table.

Recommended approach is similar how XML document is created with System.Xml.Linq.XElement.

Extensive usage of this approach can be found here.

MTable type uses MarkdownWriter under the hood.

josefpihrt avatar Sep 19 '23 22:09 josefpihrt

I will try this second method out tonight.

I got the first way working before you answered, but the table output was not what I expected.

vonj avatar Sep 20 '23 05:09 vonj

@vonj any progress?

josefpihrt avatar Oct 28 '23 12:10 josefpihrt