Configuration
Options are organized into groups on Config. The former flat properties still work but are obsolete and forward to the grouped members shown below.
Flavor
Flavor- the Markdown flavor to produce (MarkdownFlavorenum):Default,GitHub,CommonMark,Slack,Telegram,MultiMarkdown,Pandoc. The single, canonical flavor selector. See Flavors.GithubFlavored- GitHub-style conversion (br, pre → fenced code, task lists) on the default writer. Tables are always GFM regardless. Distinct fromFlavor = MarkdownFlavor.GitHub(see GitHub). Defaultfalse.CommonMarkUseHtmlInlineTags- when the CommonMark flavor is selected, emit HTML for inline tags to avoid delimiter edge cases. Defaulttrue.CommonMarkIntrawordEmphasisSpacing- when the CommonMark flavor is selected, insert spaces to avoid intraword emphasis. Defaultfalse.
Formatting
Output formatting.
Formatting.CleanupSpaces- clean up unnecessary spaces in the output. Defaulttrue.Formatting.SuppressDivNewlines- remove prefixed newlines fromdivtags. Defaultfalse.Formatting.RemoveComments- remove comment tags with text. Defaultfalse.Formatting.PreAsHtml- treat<pre>(and<pre><code>) content as normal HTML instead of a code block. Defaultfalse.Formatting.EscapeLineStarts- escape markdown line starts (headings, lists, block markers) in plain-text output. Defaultfalse.Formatting.OutputLineEnding- output line endings. DefaultEnvironment.NewLine.Formatting.ListBulletChar- the unordered-list bullet character. Default-(some systems expect*). Ignored for the Slack flavor, which always uses•.Formatting.DefaultCodeBlockLanguage- default GFM code block language when class-based language markers are absent.
Links
Links.SmartHref- how to handle an<a>href.false(default) - outputs[{name}]({href}{title})even if name and href are identical.true- if name and href are equal, outputs just thename(with http/https andtel:/mailto:refinements). If the Uri is not well formed, markdown syntax is used anyway.
Links.WhitelistedSchemes- schemes (without trailing colon) allowed for<a>/<img>. Others are bypassed. Empty (default) allows everything.
Tables
Tables.WithoutHeaderRow- handle a table without a header row.TableWithoutHeaderRowHandlingOption.Default- first row is used as the header (default).TableWithoutHeaderRowHandlingOption.EmptyRow- an empty header row is added.
Tables.HeaderColumnSpans- handle table header columns with column spans. Defaulttrue.
Tags
Tags.Unknown- handle unknown tags.UnknownTagsOption.PassThrough- include the tag plus text (default).UnknownTagsOption.Drop- drop the tag and its content.UnknownTagsOption.Bypass- ignore the tag but convert its content.UnknownTagsOption.Raise- raise an error.
Tags.Replacer- optional markdown wrappers for unknown tags. Key = tag name, value = prefix/suffix wrapper. Example:{ ["u"] = "*" }.Tags.Aliases- treat a tag as another tag. Example:{ ["u"] = "em" }.Tags.PassThrough- tags to pass through as-is without processing.
Images
Images.Base64Handling- how base64-encoded images (inline data URIs) are handled.Base64ImageHandling.Include- include as-is (default).Base64ImageHandling.Skip- ignore them entirely.Base64ImageHandling.SaveToFile- save to disk and reference the path. RequiresImages.Base64Directory.
Images.Base64Directory- directory to save images to whenBase64HandlingisSaveToFile.Images.Base64FileName-Func<int, string, string>generating a filename (without extension) from the image index and MIME type. Defaults toimage_0,image_1, …Images.LazySrcFallback- when enabled, an<img>whosesrcis empty or adata:placeholder falls back to the first usable URL inImages.LazySourceAttributes. Defaultfalse.Images.LazySourceAttributes- ordered attributes consulted (first usable wins). Defaults todata-src,data-original,data-lazy-src,data-srcset,data-original-src.
Base64 image examples
csharp
snippet source | anchor// Skip base64 images
var skip = new Config { Images = { Base64Handling = Config.Base64ImageHandling.Skip } };
// Save base64 images to disk
var save = new Config
{
Images =
{
Base64Handling = Config.Base64ImageHandling.SaveToFile,
Base64Directory = "/path/to/images",
Base64FileName = (index, mime) => $"image_{index}",
},
};Html
HTML pre-filtering (v6 Markdown DOM path).
Html.ExcludeSelectors- CSS selectors whose matching elements are removed before conversion.Html.ElementFilters- predicate filters; an element for which any predicate returns true is removed.
csharp
snippet source | anchorvar config = new Config();
config.Html.ExcludeSelectors.Add("div.advertisement, aside.related");
config.Html.ElementFilters.Add(el => el.ClassList.Contains("tracking"));