Configuration
All options live on ReverseMarkdown.Config and are passed to the converter:
cs
var config = new ReverseMarkdown.Config
{
GithubFlavored = true,
SmartHrefHandling = true,
RemoveComments = true
};
var converter = new ReverseMarkdown.Converter(config);Flavors
These flags select the output style. See Flavors for details.
GithubFlavored- GitHub-style markdown forbr,pre, and tables. Defaultfalse. Tables are always converted to GitHub-flavored markdown regardless of this flag.SlackFlavored- Slack mrkdwn. Uses*for bold,_for italic,~for strikethrough, and•for list bullets. Defaultfalse.TelegramMarkdownV2- Telegram MarkdownV2 formatting and escaping rules. Falls back to readable text for unsupported constructs (<img>to link label,<table>to preformatted block,<sup>to caret notation). Defaultfalse.CommonMark- CommonMark-focused output rules. Defaultfalse.CommonMarkUseHtmlInlineTags- When CommonMark is enabled, emit HTML for inline tags (em,strong,a,img) to avoid delimiter edge cases. Defaulttrue.CommonMarkIntrawordEmphasisSpacing- When CommonMark is enabled, insert spaces to avoid intraword emphasis. Defaultfalse.
Links
SmartHrefHandling- How to handle an<a>tag'shref.false(default) - outputs[{name}]({href}{title})even when the name and href are identical.true- when the name and href are equal, outputs just thename. If the URI is not well-formed perUri.IsWellFormedUriString, markdown link syntax is used anyway. Whenhrefcontains anhttp/httpsprotocol andnamedoes not but they are otherwise the same, thehrefis output. For atel:ormailto:scheme that is otherwise identical to the name, thenameis output.
WhitelistUriSchemes- Schemes (without trailing colon) allowed for<a>and<img>. Others are bypassed (text or nothing). AHashSet<string>; use.Add()to add schemes. Allows everything by default. Ifstring.Emptyis provided and a scheme cannot be determined, it is whitelisted. The scheme is determined by theUriclass, except when a url begins with/(file scheme) or//(http scheme).
cs
var config = new ReverseMarkdown.Config();
config.WhitelistUriSchemes.Add("http");
config.WhitelistUriSchemes.Add("https");
config.WhitelistUriSchemes.Add("mailto");Tables
TableWithoutHeaderRowHandling- How a table without a header row is handled.TableWithoutHeaderRowHandlingOption.Default- the first row becomes the header row (default).TableWithoutHeaderRowHandlingOption.EmptyRow- an empty header row is added.
TableHeaderColumnSpanHandling- Handle table header columns that use column spans. Defaulttrue.
Images
Base64Images- How base64-encoded images (inline data URIs) are handled.Base64ImageHandling.Include- include base64 images as-is (default).Base64ImageHandling.Skip- skip base64 images entirely.Base64ImageHandling.SaveToFile- save base64 images to disk and reference the saved path. RequiresBase64ImageSaveDirectory.
Base64ImageSaveDirectory- Directory to save images to whenBase64ImagesisSaveToFile.Base64ImageFileNameGenerator-Func<int, string, string>receiving the image index and MIME type, returning a filename without extension. Defaults toimage_0,image_1, and so on.LazyImageSrcFallback- When enabled, an<img>whosesrcis empty or adata:placeholder (as used by JavaScript lazy-loading libraries) falls back to the first usable URL inLazyImageSourceAttributes. Defaultfalse.LazyImageSourceAttributes- Ordered list of attributes consulted (first usable wins) whenLazyImageSrcFallbackis enabled. Defaults todata-src,data-original,data-lazy-src,data-srcset,data-original-src(srcset-style values use their first URL).
Supported image formats when saving: PNG, JPEG, GIF, BMP, TIFF, WebP, and SVG.
cs
var config = new ReverseMarkdown.Config
{
Base64Images = Config.Base64ImageHandling.SaveToFile,
Base64ImageSaveDirectory = "/path/to/images",
Base64ImageFileNameGenerator = (index, mimeType) => $"converted_{index}"
};Tags
UnknownTags- How unknown (unsupported) tags are handled.UnknownTagsOption.PassThrough- include the unknown tag and its text in the output (default).UnknownTagsOption.Drop- drop the unknown tag and its content.UnknownTagsOption.Bypass- ignore the tag but convert its content.UnknownTagsOption.Raise- raise an error.
UnknownTagsReplacer- Optional markdown wrappers for unknown tags. Key is the tag name; value is the wrapper used as prefix and suffix around converted content, for example{ ["u"] = "*" }.TagAliases- Optional alias map that treats a tag as another tag during conversion, for example{ ["u"] = "em" }.PassThroughTags- AHashSet<string>of tags to pass through as-is without processing.
Formatting
DefaultCodeBlockLanguage{#defaultcodeblocklanguage} - Default code block language for GitHub-style markdown when class-based language markers are absent.ListBulletChar{#listbulletchar} - Bullet character for unordered lists. Default-. Some systems expect*. Ignored whenSlackFlavoredis enabled (Slack always uses•).OutputLineEnding- Output line endings for the generated markdown. Defaults toEnvironment.NewLine.CleanupUnnecessarySpaces- Clean up unnecessary spaces in the output. Defaulttrue.SuppressDivNewlines- Remove the prefixed newlines adivwould otherwise introduce. Defaultfalse.ConvertPreContentAsHtml- Treat<pre>(and<pre><code>) content as normal HTML instead of a code block. Defaultfalse.EscapeMarkdownLineStarts- Escape markdown line starts (headings, lists, block markers) in plain-text output, so markdown-like text is preserved literally. Defaultfalse.RemoveComments- Remove HTML comments (and their text) from the output. Defaultfalse.
