Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

MarkdownHtmlExportOptions

OfficeIMO.Markdown

Namespace
OfficeIMO.Markdown
Assembly
OfficeIMO.Markdown
Source revision
e163ccb36643 with working tree changes
Modifiers
sealed

Options controlling HTML rendering style and asset delivery.

Inheritance

  • object
  • MarkdownHtmlExportOptions

Usage

Explore 22 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 19

Constructors

public MarkdownHtmlExportOptions() #

Methods

public static MarkdownHtmlExportOptions CreateGitHubFlavoredMarkdownProfile() #

Creates a fragment-oriented HTML rendering profile for GitHub Flavored Markdown comparison/output. This enables cmark-gfm-style task-list HTML, footnote HTML, and the GFM raw HTML tag filter while leaving raw HTML otherwise allowed. Use a stricter MarkdownRawHtmlHandling value for untrusted hosts.

Properties

public bool FailOnLoss { get; set; } #

Blocks conversion when any fidelity loss is reported.

public bool IncludeCssInFragment { get; set; } #

Includes CSS and scripts when rendering a fragment as one self-contained string.

public MarkdownHtmlKind Kind { get; set; } #

Fragment vs full document. Default: MarkdownHtmlKind.Fragment.

public MarkdownHtmlStyle Style { get; set; } #

Built-in style preset. Default: MarkdownHtmlStyle.Clean.

public MarkdownCssDelivery CssDelivery { get; set; } #

How to deliver CSS. Default: MarkdownCssDelivery.Inline.

public MarkdownAssetMode AssetMode { get; set; } #

Connectivity mode for external assets (CDNs). Default: MarkdownAssetMode.Online.

public string? CssHref { get; set; } #

Optional explicit CSS URL for MarkdownCssDelivery.LinkHref.

public List<string> AdditionalCssHrefs { get; } #

Additional CSS URLs to include (link or inline depending on MarkdownAssetMode).

public List<string> AdditionalJsHrefs { get; } #

Additional JS URLs to include (script src or inline depending on MarkdownAssetMode).

public MarkdownExternalTextResolver? ExternalTextResolver { get; set; } #

Optional caller-owned resolver used to inline HTTP or HTTPS CSS and JavaScript in offline mode. OfficeIMO never performs hidden synchronous network requests; return null to omit a resource.

public string Title { get; set; } #

Page title for full document rendering. Default: "Document".

public string? BodyClass { get; set; } #

Wrap content in <article> with this CSS class. Set to null to avoid wrapper. Default: "markdown-body".

public bool AutoHeadingIdentifiers { get; set; } #

When true, headings render automatic id attributes. Default: true to preserve OfficeIMO's existing HTML output behavior.

public MarkdownHeadingIdentifierStyle HeadingIdentifierStyle { get; set; } #

Controls the slug algorithm used for automatic heading identifiers.

public bool ShowAnchorIcons { get; set; } #

When true, show a small anchor icon next to headings (on hover by default).

public string AnchorIcon { get; set; } #

Glyph or text for the anchor icon (e.g., "🔗", "¶"). Default: "🔗".

public bool CopyHeadingLinkOnClick { get; set; } #

When true, clicking the anchor icon copies a deep link to the clipboard.

public int BackToTopMinLevel { get; set; } #

Heading level threshold for BackToTopLinks. Default: 2 (MarkdownH2+).

public string BackToTopText { get; set; } #

Text for the back-to-top link.

public bool ThemeToggle { get; set; } #

When true, writes a small theme toggle control if MarkdownHtmlExportOptions.Style supports it. Default: false.

public MarkdownAssetEmitMode EmitMode { get; set; } #

Emit tags vs manifest-only. Default: MarkdownAssetEmitMode.Emit.

public MarkdownPrismOptions? Prism { get; set; } #

Optional Prism highlighting configuration.

public MarkdownCodeBlockHtmlRenderer? CodeBlockHtmlRenderer { get; set; } #

Optional callback that can replace HTML emitted for individual code blocks. Returning null falls back to the default <pre><code> rendering.

public MarkdownSemanticFencedBlockHtmlRenderer? SemanticFencedBlockHtmlRenderer { get; set; } #

Optional callback that can replace HTML emitted for semantic fenced blocks. Returning null falls back to standard fenced-code presentation.

public MarkdownTocHtmlRenderer? TocHtmlRenderer { get; set; } #

Optional callback that can replace HTML emitted for realized TOC placeholders. Returning null falls back to the built-in enhanced TOC rendering.

public MarkdownFootnoteSectionHtmlRenderer? FootnoteSectionHtmlRenderer { get; set; } #

Optional callback that can replace HTML emitted for the aggregated footnote section. Returning null falls back to the built-in section/ordered-list rendering.

public bool GitHubTaskListHtml { get; set; } #

When true, task lists render using GitHub/cmark-gfm style HTML without OfficeIMO task-list CSS classes. Default: false.

public bool GitHubFootnoteHtml { get; set; } #

When true, footnote references and sections render using GitHub/cmark-gfm style ids, data attributes, numbering by reference order, and omission of undefined/unused footnotes. Default: false.

public bool GitHubHtmlTagFilter { get; set; } #

When true, raw HTML rendering applies cmark-gfm's tag filter by escaping the leading < on dangerous raw HTML tags such as script, style, textarea, and xmp. Default: false.

public bool NormalizeUrlHostsToIdn { get; set; } #

When true, non-ASCII authority host labels in rendered URL attributes are normalized to IDNA. Disable this for cmark-gfm-style output, which percent-encodes those host characters instead.

public bool PercentEncodeTildeInUrlAttributes { get; set; } #

When true, rendered URL attributes percent-encode the ASCII tilde character (~). Default: false; enable for Markdig-compatible URL attribute output.

public bool EscapeNonAsciiText { get; set; } #

When true, HTML text rendering uses the historical .NET encoder behavior that may emit numeric character references for non-ASCII text. Set to false for Markdig/cmark-style output that keeps non-ASCII text literal while still escaping HTML-sensitive characters such as &, <, >, quotes, and apostrophes.

public List<MarkdownBlockHtmlRenderExtension> BlockRenderExtensions { get; } #

Optional block render extensions that can override HTML emitted for specific block types. Later registrations win when block types overlap.

public List<MarkdownInlineHtmlRenderExtension> InlineRenderExtensions { get; } #

Optional inline render extensions that can override HTML emitted for specific inline types. Later registrations win when inline types overlap.

public List<MarkdownSyntaxBlockHtmlRenderExtension> SyntaxBlockRenderExtensions { get; } #

Optional block render extensions that can override HTML emitted for parsed blocks with specific final syntax kinds. Later registrations win when syntax kinds overlap. These extensions run before type-based block extensions.

public List<MarkdownSyntaxInlineHtmlRenderExtension> SyntaxInlineRenderExtensions { get; } #

Optional inline render extensions that can override HTML emitted for parsed inlines with specific final syntax kinds. Later registrations win when syntax kinds overlap. These extensions run before type-based inline extensions.

public string? CssScopeSelector { get; set; } #

Prefix selectors in emitted CSS with this scope selector to avoid collisions. Default: "article.markdown-body".

public MarkdownRawHtmlHandling RawHtmlHandling { get; set; } #

Controls how raw HTML blocks and inline fragments are emitted. Default: MarkdownRawHtmlHandling.Allow. For untrusted chat scenarios, prefer MarkdownRawHtmlHandling.Strip or MarkdownRawHtmlHandling.Escape.

public bool ExternalLinksTargetBlank { get; set; } #

When true, external HTTP(S) links are rendered with target="_blank". Default: false.

public string ExternalLinksRel { get; set; } #

Optional rel attribute value to apply to external HTTP(S) links. Common safe value: noopener noreferrer. Default: empty (no rel attribute added).

public string ExternalLinksReferrerPolicy { get; set; } #

Optional referrerpolicy value to apply to external HTTP(S) links. Common privacy value: no-referrer. Default: empty (no referrerpolicy attribute added).

public Uri? BaseUri { get; set; } #

Optional base URI used for origin-based restrictions during HTML rendering. When set and MarkdownHtmlExportOptions.RestrictHttpLinksToBaseOrigin/MarkdownHtmlExportOptions.RestrictHttpImagesToBaseOrigin are enabled, absolute HTTP(S) links/images that are cross-origin are suppressed. Default: null.

public bool RestrictHttpLinksToBaseOrigin { get; set; } #

When true and MarkdownHtmlExportOptions.BaseUri is an absolute HTTP(S) URI, suppresses cross-origin absolute HTTP(S) links. Relative links and non-HTTP schemes (e.g., mailto) are not affected. Default: false.

public bool RestrictHttpImagesToBaseOrigin { get; set; } #

When true and MarkdownHtmlExportOptions.BaseUri is an absolute HTTP(S) URI, suppresses cross-origin absolute HTTP(S) images. Relative image URLs are not affected. Default: false.

public bool BlockExternalHttpImages { get; set; } #

When true, suppresses absolute external HTTP(S) images regardless of MarkdownHtmlExportOptions.BaseUri. Useful for privacy-sensitive/untrusted content. Default: false.

public bool ImagesLoadingLazy { get; set; } #

When true, emits loading="lazy" on rendered <img> tags. Default: false.

public bool ImagesDecodingAsync { get; set; } #

When true, emits decoding="async" on rendered <img> tags. Default: false.

public string ImagesReferrerPolicy { get; set; } #

Optional referrerpolicy value to apply to rendered <img> tags. Common privacy value: no-referrer. Default: empty (no referrerpolicy attribute added).

public List<string> AllowedHttpLinkHosts { get; } #

Optional allowlist of host patterns for absolute HTTP(S) links during HTML rendering. When non-empty, absolute HTTP(S) links are suppressed unless their host matches an entry. Supported patterns: - example.com: exact host match - .example.com: example.com and any subdomain - *.example.com: any subdomain only (not the apex) Default: empty (allow all hosts).

public List<string> AdditionalAllowedLinkSchemes { get; } #

Additional URL schemes permitted for rendered hyperlinks beyond the built-in http, https, mailto, tel, ftp, and urn schemes. Keep this list empty for untrusted Markdown. Add only application-specific schemes whose protocol handlers are safe for the rendering host.

public List<string> AllowedHttpImageHosts { get; } #

Optional allowlist of host patterns for absolute HTTP(S) images during HTML rendering. When non-empty, absolute HTTP(S) images are suppressed unless their host matches an entry. Pattern rules match MarkdownHtmlExportOptions.AllowedHttpLinkHosts. Default: empty (allow all hosts).

public MarkdownVisualTheme? Theme { get; set; } #

Shared visual theme used to keep Markdown HTML, PDF, and Word exports visually aligned.

public bool ApplyDefaultTheme { get; set; } #

Applies the shared default visual theme when MarkdownHtmlExportOptions.Theme is omitted and the selected HTML style supports document theming.

public MarkdownHtmlColorOverrides ColorOverrides { get; set; } #

Optional additional color overrides for links, headings, and TOC. Values set here override colors derived from MarkdownHtmlExportOptions.Theme.

public bool InjectTocAtTop { get; set; } #

When true, injects a MarkdownTable of Contents at the top of the document before rendering HTML. This is applied by host pipelines that have access to the MarkdownDocument model.

public string InjectTocTitle { get; set; } #

Title for the injected TOC. Default: "Contents".

public int InjectTocMinLevel { get; set; } #

Minimum heading level to include in injected TOC. Default: 1.

public int InjectTocMaxLevel { get; set; } #

Maximum heading level to include in injected TOC. Default: 3.

public bool InjectTocOrdered { get; set; } #

Whether the injected TOC should be ordered (true) or unordered (false). Default: false.

public int InjectTocTitleLevel { get; set; } #

Heading level used for the TOC title. Default: 2.