API Reference
HtmlToMarkdownOptions
Options controlling HTML to Markdown conversion.
Inheritance
- Object
- HtmlToMarkdownOptions
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Property HtmlElementBlockConversionContext.Options
- Property HtmlInlineElementConversionContext.Options
- Method HtmlToMarkdownOptions.Clone
- Method HtmlToMarkdownOptions.CreateCommonMarkProfile
- Method HtmlToMarkdownOptions.CreateGitHubFlavoredMarkdownProfile
- Method HtmlToMarkdownOptions.CreateOfficeIMOProfile
- Method HtmlToMarkdownOptions.CreatePortableProfile
- Method HtmlToMarkdownOptions.CreateProfile
Accepted by parameters
- Method HtmlMarkdownConverterExtensions.SaveAsMarkdown
- Method HtmlMarkdownConverterExtensions.SaveAsMarkdown
- Method HtmlMarkdownConverterExtensions.SaveAsMarkdownAsync
- Method HtmlMarkdownConverterExtensions.SaveAsMarkdownAsync
- Method HtmlMarkdownConverterExtensions.ToMarkdown
- Method HtmlMarkdownConverterExtensions.ToMarkdownDocument
- Method HtmlMarkdownConverterExtensions.ToMarkdownDocumentResult
Constructors
public HtmlToMarkdownOptions() #Methods
public HtmlToMarkdownOptions Clone() #HtmlToMarkdownOptionsCreates a copy of the current options instance so callers can reuse option templates safely.
Returns
A new HtmlToMarkdownOptions with the same option values.
public static HtmlToMarkdownOptions CreateCommonMarkProfile() #HtmlToMarkdownOptionsCreates a CommonMark-oriented conversion profile. The intermediate OfficeIMO document model is preserved, while markdown serialization avoids GitHub-only output where practical.
public static HtmlToMarkdownOptions CreateGitHubFlavoredMarkdownProfile() #HtmlToMarkdownOptionsCreates a GitHub Flavored Markdown-oriented conversion profile for README and GitHub documentation output.
public static HtmlToMarkdownOptions CreateOfficeIMOProfile() #HtmlToMarkdownOptionsCreates the default OfficeIMO-flavored conversion profile.
public static HtmlToMarkdownOptions CreatePortableProfile() #HtmlToMarkdownOptionsCreates a portable conversion profile that serializes the converted document with portable markdown fallbacks.
public static HtmlToMarkdownOptions CreateProfile(MarkdownOutputProfile profile) #HtmlToMarkdownOptionsCreates conversion options for the requested Markdown output profile.
Parameters
- profile OfficeIMO.Markdown.MarkdownOutputProfile
public Boolean HasFeaturePackId(String featurePackId) #BooleanReturns true when the supplied renderer feature-pack id has already been applied as an HTML-ingestion contract to these options.
Parameters
- featurePackId System.String
public Boolean HasPluginId(String pluginId) #BooleanReturns true when the supplied renderer plugin id has already been applied as an HTML-ingestion contract to these options.
Parameters
- pluginId System.String
public Boolean TryMarkFeaturePackApplied(String featurePackId) #BooleanMarks a renderer feature pack's HTML-ingestion contract as applied to these options.
Parameters
- featurePackId System.String
public Boolean TryMarkPluginApplied(String pluginId) #BooleanMarks a renderer plugin's HTML-ingestion contract as applied to these options.
Parameters
- pluginId System.String
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public Uri BaseUri { get; set; } #Optional base URI used to resolve relative links and image sources.
public Boolean UseBodyContentsOnly { get; set; } #When true, only the body contents are converted when a body element is present.
public Boolean RemoveScriptsAndStyles { get; set; } #When true, script/style/noscript/template elements are ignored.
public Boolean PreserveUnsupportedBlocks { get; set; } #When true, unsupported block elements are emitted as raw HTML blocks instead of being dropped.
public Boolean PreserveUnsupportedInlineHtml { get; set; } #When true, unsupported inline elements are emitted as raw HTML inside inline Markdown.
public Boolean SmartHref { get; set; } #When true, links whose label already represents the target are emitted as plain text.
public HtmlUnknownTagHandling UnknownBlockHandling { get; set; } #Controls how unsupported block-level elements are converted.
public HtmlUnknownTagHandling UnknownInlineHandling { get; set; } #Controls how unsupported inline elements are converted.
public Boolean EscapeMarkdownLineStarts { get; set; } #When true, plain text imported from HTML is escaped when it could be interpreted as a Markdown block marker.
public HtmlUrlPolicy UrlPolicy { get; set; } #Shared URL policy applied before hyperlink URLs are materialized into the Markdown model.
public HtmlUrlPolicy ResourceUrlPolicy { get; set; } #Optional separate policy for image and media sources. When omitted, UrlPolicy is used so existing callers retain their single-policy behavior.
public HtmlBase64ImageHandling Base64Images { get; set; } #Controls how base64 data-URI images are represented in the converted image model.
public String Base64ImageOutputDirectory { get; set; } #Output directory used when Base64Images is SaveToFile.
public Func<Int32, String, String> Base64ImageFileNameGenerator { get; set; } #Optional file name factory used when saving base64 image data. Arguments are the zero-based image index and MIME type.
public HtmlListingCardMetadataMode ListingCardMetadataMode { get; set; } #Controls whether low-value metadata inside repeated listing cards should be preserved or suppressed.
public MarkdownWriteOptions MarkdownWriteOptions { get; set; } #Optional markdown writer options used when the converter serializes the intermediate MarkdownDoc back to markdown text.
public Nullable<Int32> MaxInputCharacters { get; set; } #Optional maximum input length, in characters, accepted by HTML-to-markdown conversion. When set and exceeded, conversion fails fast with an ArgumentOutOfRangeException.
public Int32 MaxTableExpandedColumns { get; set; } #Maximum logical columns produced by expanding HTML table colspan attributes. Values must be between 1 and 4096.
public Int32 MaxDefinitionListEntryExpansions { get; set; } #Maximum number of term/definition entry pairs materialized while converting HTML definition lists. Values must be between 1 and 1,000,000.
public List<IMarkdownDocumentTransform> DocumentTransforms { get; } #Optional ordered post-conversion document transforms applied to the intermediate MarkdownDoc.
Examples
var options = HtmlToMarkdownOptions.CreatePortableProfile();
options.DocumentTransforms.Add(
new MarkdownJsonVisualCodeBlockTransform(MarkdownVisualFenceLanguageMode.GenericSemanticFence));
var document = HtmlConversionDocument.Parse(html).ToMarkdownDocument(options);
public List<HtmlElementBlockConverter> ElementBlockConverters { get; } #Optional ordered custom HTML element block converters used before the base converter falls back to generic block handling.
public List<HtmlInlineElementConverter> InlineElementConverters { get; } #Optional ordered custom HTML inline element converters used before the base converter falls back to generic inline handling.
public List<MarkdownVisualElementRoundTripHint> VisualElementRoundTripHints { get; } #Optional ordered visual-host round-trip hints used when shared data-omd-* elements should recover richer semantic fenced blocks than the default visual-contract mapping.
public HashSet<String> ExcludeSelectors { get; } #CSS selectors for elements that should be removed before conversion.
public List<Func<HtmlElement, Boolean>> ElementFilters { get; } #Predicates for elements that should be removed before conversion. Return true to remove an element.
public Dictionary<String, String> TagAliases { get; } #Maps an HTML tag name to another tag name before built-in conversion is selected.
public HashSet<String> PassThroughTags { get; } #Tag names that should be emitted as raw HTML without converting their children.