Search code examples
c#markdowndeep

MarkdownDeep AutoHeadingIDs are not working


I'm working with MarkdownDeep in my WebSite:

public static MvcHtmlString FromMarkdown(this HtmlHelper helper, string value)
{
    var md = new Markdown
    {
        ExtraMode = true,
        SafeMode = true,
        NewWindowForExternalLinks = true,
        MarkdownInHtml = true,
        AutoHeadingIDs = true
    };

    text = md.Transform(value);

    return MvcHtmlString.Create(text);
}

My problem here is, that headings still not get IDs since I want to work with anchors. Anyone an idea?


Solution

  • The problem was that you can't use property SafeMode together with AutoHeadingIDs. It's not documented but it solved my problem. Initialization now looks:

    var md = new Markdown
    {
        ExtraMode = true,
        NewWindowForExternalLinks = true,
        MarkdownInHtml = true,
        AutoHeadingIDs = true
    };