MarkdownExportAsHtml

MarkdownExportAsHtml enumeration

Allows to specify the elements to be exported to Markdown as raw HTML.

[Flags]
public enum MarkdownExportAsHtml

Values

NameValueDescription
None0Export all elements using Markdown syntax without any raw HTML.
Tables1Export tables as raw HTML.
NonCompatibleTables2Export tables that cannot be correctly represented in pure Markdown as raw HTML.

Examples

Shows how to export tables that cannot be correctly represented in pure Markdown as raw HTML.

string outputPath = ArtifactsDir + "MarkdownSaveOptions.NonCompatibleTables.md";

Document doc = new Document(MyDir + "Non compatible table.docx");

// With the "NonCompatibleTables" option, you can export tables that have a complex structure with merged cells
// or nested tables to raw HTML and leave simple tables in Markdown format.
MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();
saveOptions.ExportAsHtml = MarkdownExportAsHtml.NonCompatibleTables;

doc.Save(outputPath, saveOptions);

Shows how to export a table to Markdown as raw HTML.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Sample table:");

// Create table.
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write("Cell1");
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Write("Cell2");

MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();
saveOptions.ExportAsHtml = MarkdownExportAsHtml.Tables;

doc.Save(ArtifactsDir + "MarkdownSaveOptions.ExportTableAsHtml.md", saveOptions);

See Also