API Reference
MarkdownDoc
Root document container and fluent API entrypoint for composing Markdown. Supports a fluent-chaining style and an explicit object model via IMarkdownBlock).
Inheritance
- MarkdownObject
- MarkdownDoc
Constructors
public MarkdownDoc() #Methods
public MarkdownDoc Add(IMarkdownBlock block) #MarkdownDocAdds a block instance (object-model style).
Parameters
- block OfficeIMO.Markdown.IMarkdownBlock
- Block to append to the document.
Returns
Same MarkdownDoc for chaining.
public MarkdownDoc Callout(String kind, String title, String body) #MarkdownDocAdds a callout/admonition block (Docs-style).
Parameters
- kind System.String
- title System.String
- body System.String
public MarkdownDoc Caption(String caption) #MarkdownDocSets a caption for the last captionable block (image/code), or appends a paragraph.
Parameters
- caption System.String
public MarkdownDoc Code(String language, String content) #MarkdownDocAdds a fenced code block.
Parameters
- language System.String
- content System.String
public IEnumerable<HeadingBlock> DescendantHeadings() #IEnumerable<HeadingBlock>Enumerates all headings in document order, including nested headings.
public IEnumerable<ListItem> DescendantListItems() #IEnumerable<ListItem>Enumerates all list items in document order, including nested items.
public IEnumerable<IMarkdownBlock> DescendantsAndSelf() #IEnumerable<IMarkdownBlock>Enumerates all document blocks depth-first, including front matter when present.
public IEnumerable<TBlock> DescendantsOfType<TBlock>() #IEnumerable<TBlock>Type Parameters
- TBlock
DescendantsOfType``1() #Enumerates all document blocks of the requested type depth-first.
public IEnumerable<TableCell> DescendantTableCells() #IEnumerable<TableCell>Enumerates all table cells in document order, including header cells and nested tables.
public IEnumerable<TableBlock> DescendantTables() #IEnumerable<TableBlock>Enumerates all tables in document order, including nested tables.
public MarkdownDoc Details(String summary, Action<MarkdownDoc> buildBody, Boolean open = false) #MarkdownDocAdds a collapsible details block.
Parameters
- summary System.String
- buildBody System.Action{OfficeIMO.Markdown.MarkdownDoc}
- open System.Boolean = false
public MarkdownDoc Dl(Action<DefinitionListBuilder> build) #MarkdownDocAdds a definition list.
Parameters
- build System.Action{OfficeIMO.Markdown.DefinitionListBuilder}
FindFirstDescendantOfType``1() #Finds the first document block of the requested type depth-first.
FindFirstTopLevelBlockOfType``1() #Finds the first top-level document block of the requested type.
public Entry FindFrontMatterEntry(String key, StringComparison comparison = OrdinalIgnoreCase) #EntryFinds a front matter entry by key when the document header is present.
Parameters
- key System.String
- comparison System.StringComparison = OrdinalIgnoreCase
public HeadingInfo FindHeading(String text, StringComparison comparison = OrdinalIgnoreCase) #HeadingInfoFinds the first heading whose plain text matches the provided heading text.
Parameters
- text System.String
- comparison System.StringComparison = OrdinalIgnoreCase
public HeadingInfo FindHeadingByAnchor(String anchor) #HeadingInfoFinds the heading with the specified resolved anchor, if present.
Parameters
- anchor System.String
public IReadOnlyList<HeadingInfo> FindHeadings(String text, StringComparison comparison = OrdinalIgnoreCase) #IReadOnlyList<HeadingInfo>Finds headings whose plain text matches the provided heading text.
Parameters
- text System.String
- comparison System.StringComparison = OrdinalIgnoreCase
public MarkdownDoc FrontMatter(Object data) #MarkdownDocSets YAML front matter from an anonymous object or dictionary.
Parameters
- data System.Object
public String GetHeadingAnchor(HeadingBlock heading) #StringGets the resolved anchor id for a heading within this document.
Parameters
- heading OfficeIMO.Markdown.HeadingBlock
public IReadOnlyList<HeadingInfo> GetHeadingInfos() #IReadOnlyList<HeadingInfo>Returns resolved heading metadata in document order.
public MarkdownDoc H1(String text) #MarkdownDocAdds an H1 heading.
Parameters
- text System.String
public MarkdownDoc H2(String text) #MarkdownDocAdds an H2 heading.
Parameters
- text System.String
public MarkdownDoc H3(String text) #MarkdownDocAdds an H3 heading.
Parameters
- text System.String
public MarkdownDoc H4(String text) #MarkdownDocAdds an H4 heading.
Parameters
- text System.String
public MarkdownDoc H5(String text) #MarkdownDocAdds an H5 heading.
Parameters
- text System.String
public MarkdownDoc H6(String text) #MarkdownDocAdds an H6 heading.
Parameters
- text System.String
HasDescendantOfType``1() #Checks whether the document has any block of the requested type depth-first.
public Boolean HasFrontMatterEntry(String key, StringComparison comparison = OrdinalIgnoreCase) #BooleanChecks whether the document header contains an entry with the specified key.
Parameters
- key System.String
- comparison System.StringComparison = OrdinalIgnoreCase
public Boolean HasHeading(String text, StringComparison comparison = OrdinalIgnoreCase) #BooleanChecks whether a heading whose plain text matches the provided heading text is present.
Parameters
- text System.String
- comparison System.StringComparison = OrdinalIgnoreCase
public Boolean HasHeadingAnchor(String anchor) #BooleanChecks whether a heading with the specified resolved anchor is present.
Parameters
- anchor System.String
HasTopLevelBlockOfType``1() #Checks whether the document has a top-level block of the requested type.
public MarkdownDoc Image(String path, String alt, String title) #MarkdownDocAdds an image block with optional alt text and title.
Parameters
- path System.String
- alt System.String
- title System.String
public MarkdownDoc Image(String path, String alt = null, String title = null, Nullable<Double> width = null, Nullable<Double> height = null) #MarkdownDocAdds an image block with optional alt text, title, and size hints.
Parameters
- path System.String
- alt System.String = null
- title System.String = null
- width System.Nullable{System.Double} = null
- height System.Nullable{System.Double} = null
public MarkdownDoc Ol<T>(IEnumerable<T> items, Int32 start = 1) #MarkdownDocAdds an ordered list.
Type Parameters
- T
Parameters
- build System.Action{OfficeIMO.Markdown.OrderedListBuilder}
Ol``1(System.Collections.Generic.IEnumerable{``0} items, System.Int32 start) #Adds an ordered list from a sequence of items using ToString().
Parameters
- items System.Collections.Generic.IEnumerable{``0}
- start System.Int32
public MarkdownDoc P(Action<ParagraphBuilder> build) #MarkdownDocAdds a paragraph with plain text.
Parameters
- text System.String
P(System.Action{OfficeIMO.Markdown.ParagraphBuilder} build) #Adds a paragraph composed with the paragraph builder.
Parameters
- build System.Action{OfficeIMO.Markdown.ParagraphBuilder}
public MarkdownDoc Quote(Action<QuoteBuilder> build) #MarkdownDocAdds a simple block quote with a single line of text.
Parameters
- text System.String
Quote(System.Action{OfficeIMO.Markdown.QuoteBuilder} build) #Adds a block quote composed via QuoteBuilder.
Parameters
- build System.Action{OfficeIMO.Markdown.QuoteBuilder}
public MarkdownDoc Rewrite(MarkdownRewriter rewriter) #MarkdownDocRewrites the document using the provided rewriter.
Parameters
- rewriter OfficeIMO.Markdown.MarkdownRewriter
public Void SaveHtml(String path, HtmlOptions options = null) #VoidSaves HTML to the specified file. When ExternalFile is used, writes a sidecar CSS file next to the HTML and links it.
Parameters
- path System.String
- options OfficeIMO.Markdown.HtmlOptions = null
public async Task SaveHtmlAsync(String path, HtmlOptions options = null) #TaskAsynchronously saves HTML to the specified file. When ExternalFile is used, writes a sidecar CSS file next to the HTML and links it.
Parameters
- path System.String
- options OfficeIMO.Markdown.HtmlOptions = null
public MarkdownDoc Table(Action<TableBuilder> build) #MarkdownDocAdds a table built with TableBuilder.
Parameters
- build System.Action{OfficeIMO.Markdown.TableBuilder}
public MarkdownDoc TableAuto(Action<TableBuilder> build, Boolean alignNumeric = true, Boolean alignDates = true) #MarkdownDocBuilds a table via TableBuilder, then applies auto-alignment heuristics if requested.
Parameters
- build System.Action{OfficeIMO.Markdown.TableBuilder}
- alignNumeric System.Boolean = true
- alignDates System.Boolean = true
public MarkdownDoc TableFrom<T>(IEnumerable<T> items, params ValueTuple<String, Func<T, Object>>[] columns) #MarkdownDocConvenience to add a table from arbitrary data; see Object) for rules.
Type Parameters
- T
Parameters
- data System.Object
public MarkdownDoc TableFromAuto(Object data, Action<TableFromOptions> configure = null, Boolean alignNumeric = true, Boolean alignDates = true) #MarkdownDocCreates a table from data and applies auto-alignment heuristics (numeric right, dates center) if requested.
Parameters
- data System.Object
- configure System.Action{OfficeIMO.Markdown.TableFromOptions} = null
- alignNumeric System.Boolean = true
- alignDates System.Boolean = true
TableFrom``1(System.Collections.Generic.IEnumerable{``0} items, System.ValueTuple{System.String,System.Func{``0,System.Object}}[] columns) #Convenience to add a table from a sequence using column selectors.
Parameters
- items System.Collections.Generic.IEnumerable{``0}
- columns System.ValueTuple{System.String,System.Func{``0,System.Object}}[]
public MarkdownDoc Toc(Action<TocOptions> configure = null, Boolean placeAtTop = false) #MarkdownDocGenerates a Table of Contents from headings already present in the document and inserts it.
Parameters
- configure System.Action{OfficeIMO.Markdown.TocOptions} = null
- Optional TOC options.
- placeAtTop System.Boolean = false
- When true, inserts TOC as the first block; otherwise appended.
public MarkdownDoc TocAtTop(String title = "Contents", Int32 min = 1, Int32 max = 3, Boolean ordered = false, Int32 titleLevel = 2) #MarkdownDocConvenience helper to insert a Table of Contents at the top with common parameters.
Parameters
- title System.String = "Contents"
- min System.Int32 = 1
- max System.Int32 = 3
- ordered System.Boolean = false
- titleLevel System.Int32 = 2
public MarkdownDoc TocForPreviousHeading(String title = "Contents", Int32 min = 2, Int32 max = 6, Boolean ordered = false, Int32 titleLevel = 3) #MarkdownDocInserts a section TOC for the nearest preceding heading. Useful to place a small TOC under a section.
Parameters
- title System.String = "Contents"
- min System.Int32 = 2
- max System.Int32 = 6
- ordered System.Boolean = false
- titleLevel System.Int32 = 3
public MarkdownDoc TocForSection(String headingTitle, String title = "Contents", Int32 min = 2, Int32 max = 6, Boolean ordered = false, Int32 titleLevel = 3) #MarkdownDocInserts a section TOC scoped to the named heading.
Parameters
- headingTitle System.String
- title System.String = "Contents"
- min System.Int32 = 2
- max System.Int32 = 6
- ordered System.Boolean = false
- titleLevel System.Int32 = 3
public MarkdownDoc TocHere(Action<TocOptions> configure = null) #MarkdownDocInserts a TOC placeholder at the current position without a title heading by default.
Parameters
- configure System.Action{OfficeIMO.Markdown.TocOptions} = null
public String ToHtml() #StringRenders HTML using default options. For backward compatibility, this returns an embeddable HTML fragment (no html/head/body) containing just the rendered content. Use HtmlOptions) for a full page.
public String ToHtmlDocument(HtmlOptions options = null) #StringRenders a standalone HTML5 document with optional CSS/JS assets.
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public Task<String> ToHtmlDocumentAsync(HtmlOptions options = null) #Task<String>Asynchronously renders a full HTML document.
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public String ToHtmlFragment(HtmlOptions options = null) #StringRenders an embeddable HTML fragment. Wraps in <article class="markdown-body"> by default.
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public Task<String> ToHtmlFragmentAsync(HtmlOptions options = null) #Task<String>Asynchronously renders an embeddable HTML fragment.
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public String ToHtmlFragmentWithCss(HtmlOptions options = null) #StringRenders an embeddable HTML fragment and inlines the computed CSS and tiny scripts at the top/bottom of the fragment. Useful when you want a single self-contained chunk without a full HTML document.
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public HtmlRenderParts ToHtmlParts(HtmlOptions options = null) #HtmlRenderPartsReturns rendered parts for advanced embedding (Head, Body, Css, Scripts).
Parameters
- options OfficeIMO.Markdown.HtmlOptions = null
public String ToMarkdown(MarkdownWriteOptions options) #StringRenders the document to Markdown string using optional writer extensions or portability fallbacks.
Parameters
- options OfficeIMO.Markdown.MarkdownWriteOptions
public IEnumerable<TBlock> TopLevelBlocksOfType<TBlock>() #IEnumerable<TBlock>Type Parameters
- TBlock
TopLevelBlocksOfType``1() #Enumerates top-level document blocks of the requested type.
public Boolean TryGetFrontMatterValue<T>(String key, out T value) #BooleanType Parameters
- T
Parameters
- key String
- value T
TryGetFrontMatterValue``1(System.String key, ``0@ value) #Gets a typed front matter value by key when the document header is present.
Parameters
- key System.String
- value ``0@
public MarkdownDoc Ul<T>(IEnumerable<T> items) #MarkdownDocAdds an unordered list.
Type Parameters
- T
Parameters
- build System.Action{OfficeIMO.Markdown.UnorderedListBuilder}
Ul``1(System.Collections.Generic.IEnumerable{``0} items) #Adds an unordered list from a sequence of items using ToString().
Parameters
- items System.Collections.Generic.IEnumerable{``0}
Inherited Methods
public Void Accept(MarkdownVisitor visitor) #VoidParameters
- visitor MarkdownVisitor
public IEnumerable<MarkdownObject> Ancestors() #IEnumerable<MarkdownObject>public IEnumerable<MarkdownObject> AncestorsAndSelf() #IEnumerable<MarkdownObject>public IEnumerable<TObject> DescendantObjectsOfType<TObject>() #IEnumerable<TObject>Type Parameters
- TObject
public IEnumerable<MarkdownObject> Descendants() #IEnumerable<MarkdownObject>public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public IReadOnlyList<IMarkdownBlock> Blocks { get; } #All blocks added to the document (excluding front matter).
public FrontMatterBlock DocumentHeader { get; } #Document-level front matter/header block when present.
public IReadOnlyList<Entry> FrontMatterEntries { get; } #Structured document front matter entries when present.
public IReadOnlyList<IMarkdownBlock> TopLevelBlocks { get; } #All top-level document blocks in order, including front matter when present.
public Boolean HasDocumentHeader { get; } #Whether the document has front matter.
Inherited Properties
public MarkdownObject Parent { get; } #public MarkdownDoc Document { get; } #public MarkdownObject Root { get; } #public Nullable<Int32> IndexInParent { get; } #public MarkdownObject PreviousSibling { get; } #public MarkdownObject NextSibling { get; } #public Nullable<MarkdownSourceSpan> SourceSpan { get; set; } #public IReadOnlyList<MarkdownObject> ChildObjects { get; } #