Skip to content

markdownItLoader not working as expected #3055

@andrewchernow

Description

@andrewchernow

Search terms

markdownItLoader

Expected Behavior

I am using markdownItLoader so I can load the markdown-it-link-attributes plugin. This will enable me to add a target="_blank" attribute to links. I expect [Go](https://www.go.com) to be converted to <a href="https://www.go.com" target="_blank">Go</a>

Actual Behavior

I end up with a regular link without any target attribute.

Steps to reproduce the bug

Use the below after installing markdown-it-link-attributes 4.0.1. The markdown-it version is whatever version was installed along with typedoc.

import markdownitLinkAttributes from 'markdown-it-link-attributes';

export default {
    markdownItLoader(parser) {
        parser.use(markdownitLinkAttributes, {
            attrs: {
                target: '_blank',
                rel: 'noopener',
            },
        })
    },
    ...
}

Disable all typedoc plugins.

I have a Doc Block comment and an included markdown file that both have a standard markdown link. I simply run npx typedoc. The documentation is created and looks correct. My only issue is that markdownItLoader appears to have no effect. Links do not open in a new tab: no target attribute.

I should note I also tried markdownLinkExternal but that also had no effect.

As a sanity check, I created this simple example to ensure markdown-it-link-attributes wasn't the issue.

import MarkdownIt from "markdown-it";
import markdownitLinkAttributes from 'markdown-it-link-attributes';

const md = new MarkdownIt({html: true, linkify: true});
md.use(markdownitLinkAttributes, {
    attrs: {
        target: "_blank",
        rel: "noopener",
    },
});

const result = md.render("[Go](https://www.go.com)")
console.log(result)

The above script outputs <p><a href="https://www.go.com" target="_blank" rel="noopener">Go</a></p>. Due to the linkify option, regular text links work as well.

Environment

  • TypeDoc version: 0.28.15
  • TypeScript version: 5.9.3
  • Node.js version: 22.15.1
  • OS: macOS Tahoe 26.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions